Branching fraction and effective lifetime measurements of the rare decay B_{s}^{0}→μ^{+}μ^{-} and searches for the decays B^{0}→μ^{+}μ^{-} and B_{s}^{0}→μ^{+}μ^{-}γ are reported using proton-proton collision data collected with the LHCb detector at center-of-mass energies of 7, 8, and 13 TeV, corresponding to a luminosity of 9 fb^{-1}. The branching fraction B(B_{s}^{0}→μ^{+}μ^{-})=(3.09_{-0.43-0.11}^{+0.46+0.15})×10^{-9} and the effective lifetime τ(B_{s}^{0}→μ^{+}μ^{-})=2.07±0.29±0.03 ps are measured, where the first uncertainty is statistical and the second systematic. No significant signal for B^{0}→μ^{+}μ^{-} and B_{s}^{0}→μ^{+}μ^{-}γ decays is found and upper limits B(B^{0}→μ^{+}μ^{-})<2.6×10^{-10} and B(B_{s}^{0}→μ^{+}μ^{-}γ)<2.0×10^{-9} at the 95% C.L. are determined, where the latter is limited to the range m_{μμ}>4.9 GeV/c^{2}. The results are in agreement with the standard model expectations.