The first observation of the B0s→¯D0K+K− decay is reported, together with the most precise branching fraction measurement of the mode B0→¯D0K+K−. The results are obtained from an analysis of pp collision data corresponding to an integrated luminosity of 3.0 fb−1. The data were collected with the LHCb detector at center-of-mass energies of 7 and 8 TeV. The branching fraction of the B0→¯D0K+K− decay is measured relative to that of the decay B0→¯D0π+π− to be B(B0→¯D0K+K−)B(B0→¯D0π+π−)=(6.9±0.4±0.3)%, where the first uncertainty is statistical and the second is systematic. The measured branching fraction of the B0s→¯D0K+K− decay mode relative to that of the corresponding B0 decay is B(B0s→¯D0K+K−)B(B0→¯D0K+K−)=(93.0±8.9±6.9)%. Using the known branching fraction of B0→¯D0π+π−, the values of B(B0→¯D0K+K−)=(6.1±0.4±0.3±0.3)×10−5 and B(B0s→¯D0K+K−)=(5.7±0.5±0.4±0.5)×10−5 are obtained, where the third uncertainties arise from the branching fraction of the decay modes B0→¯D0π+π− and B0→¯D0K+K−, respectively.