The time-dependent CP asymmetry in B0s→J/ψK+K− decays is measured using pp collision data, corresponding to an integrated luminosity of 3.0 fb−1, collected with the LHCb detector at center-of-mass energies of 7 and 8 TeV. In a sample of 96 000 B0s→J/ψK+K− decays, the CP-violating phase ϕs is measured, as well as the decay widths ΓL and ΓH of the light and heavy mass eigenstates of the B0s–¯B0s system. The values obtained are ϕs=−0.058±0.049±0.006 rad, Γs≡(ΓL+ΓH)/2=0.6603±0.0027±0.0015 ps−1, and ΔΓs≡ΓL−ΓH=0.0805±0.0091±0.0032 ps−1, where the first uncertainty is statistical and the second, systematic. These are the most precise single measurements of those quantities to date. A combined analysis with B0s→J/ψπ+π− decays gives ϕs=−0.010±0.039 rad. All measurements are in agreement with the standard model predictions. For the first time, the phase ϕs is measured independently for each polarization state of the K+K− system and shows no evidence for polarization dependence.