A measurement of the CP asymmetry in D0→K0SK0S decays is reported, based on a data sample of proton-proton collisions collected by the LHCb experiment from 2015 to 2018, corresponding to an integrated luminosity of 6 fb−1. The flavor of the D0 candidate is determined using the charge of the D*± meson, from which the decay is required to originate. The D0→K+K− decay is used as a calibration channel. The time-integrated CP asymmetry for the D0→K0SK0S mode is measured to be ACP(D0→K0SK0S)=(−3.1±1.2±0.4±0.2), where the first uncertainty is statistical, the second is systematic, and the third is due to the uncertainty on the CP asymmetry of the calibration channel. This is the most precise determination of this quantity to date.