  We address the contribution of the $3\pi$ channel to hadronic vacuum
polarization (HVP) using a dispersive representation of the $e^+e^-\to 3\pi$
amplitude. This channel gives the second-largest individual contribution to the
total HVP integral in the anomalous magnetic moment of the muon $(g-2)_\mu$,
both to its absolute value and uncertainty. It is largely dominated by the
narrow resonances $\omega$ and $\phi$, but not to the extent that the off-peak
regions were negligible, so that at the level of accuracy relevant for
$(g-2)_\mu$ an analysis of the available data as model independent as possible
becomes critical. Here, we provide such an analysis based on a global fit
function using analyticity and unitarity of the underlying $\gamma^*\to3\pi$
amplitude and its normalization from a chiral low-energy theorem, which, in
particular, allows us to check the internal consistency of the various
$e^+e^-\to 3\pi$ data sets. Overall, we obtain $a_\mu^{3\pi}|_{\leq
1.8\,\text{GeV}}=46.2(6)(6)\times 10^{-10}$ as our best estimate for the total
$3\pi$ contribution consistent with all (low-energy) constraints from QCD. In
combination with a recent dispersive analysis imposing the same constraints on
the $2\pi$ channel below $1\,\text{GeV}$, this covers nearly $80\%$ of the
total HVP contribution, leading to $a_\mu^\text{HVP}=692.3(3.3)\times 10^{-10}$
when the remainder is taken from the literature, and thus reaffirming the
$(g-2)_\mu$ anomaly at the level of at least $3.4\sigma$. As side products, we
find for the vacuum-polarization-subtracted masses
$M_\omega=782.63(3)(1)\,\text{MeV}$ and $M_\phi=1019.20(2)(1)\,\text{MeV}$,
confirming the tension to the $\omega$ mass as extracted from the $2\pi$
channel.
