We report a measurement of the ${\rm B^0_s}\to\mu^+\mu^-$ branching fraction and
its effective lifetime, as well as results of a search for the ${\rm B}^0\to\mu^+\mu^-$
decay in proton-proton collisions at $\sqrt{s}=13~\rm{TeV}$
at the LHC. The analysis is based on data collected with the CMS detector in
2016-2018 corresponding to an integrated luminosity of $140~{\rm fb}^{-1}$. The measured
branching fraction of the ${\rm B^0_s}\to\mu^+\mu^-$ decay and the effective
${\rm B^0_s}$ lifetime are the most precise measurements to date. No evidence
for the ${\rm B}^0\to\mu^+\mu^-$ decay has been found. All results are found to
be consistent with the standard model predictions.