  The very rare $D^{*}(2007)^0\to\mu^+\mu^-$ decay is searched for by analysing
$B^-\to\pi^-\mu^+\mu^-$ decays. The analysis uses a sample of beauty mesons
produced in proton-proton collisions collected with the LHCb detector between
2011 and 2018, corresponding to an integrated luminosity of 9 fb$^{-1}$. The
signal signature corresponds to simultaneous peaks in the $\mu^+\mu^-$ and
$\pi^-\mu^+\mu^-$ invariant masses. No evidence for an excess of events over
background is observed and an upper limit is set on the branching fraction of
the decay at ${\cal B}(D^{*}(2007)^0\to\mu^+\mu^-) < 2.6\times 10^{-8}$ at
$90\%$ confidence level. This is the first limit on the branching fraction of
$D^{*}(2007)^0\to\mu^+\mu^-$ decays and the most stringent limit on
$D^{*}(2007)^0$ decays to leptonic final states. The analysis is the first
search for a rare charm-meson decay exploiting production via beauty decays.
