A search for the $B^{0}to K^{+}K^{-}$ decay is performed using $pp$-collision data collected by LHCb. The data set corresponds to integrated luminosities of 1 and 2 fb$^{-1}$ at center-of-mass energies of 7 and 8 TeV, respectively. This decay is observed for the first time, with a significance of more than five standard deviations. The analysis also results in an improved measurement of the branching fraction for the $B_s^0to pi^+pi^-$ decay. The measured branching fractions are $BR(B^0to K^+K^-) = (7.80 pm 1.27 pm 0.81 pm 0.21) times 10^{-8}$ and $BR(B_s^0topi^+pi^-) = (6.91 pm 0.54 pm 0.63 pm 0.19 pm 0.40) times 10^{-7}$. The first uncertainty is statistical, the second is systematic, the third is due to the uncertainty on the $B^0to K^+pi^-$ branching fraction used as a normalization. For the $B_s^0$ mode, the fourth accounts for the uncertainty on the ratio of the probabilities for $b$ quarks to hadronize into $B_s^0$ and $B^0$ mesons.