  We compute the hadronic running of the electromagnetic and weak couplings in
lattice QCD with $N_{\mathrm{f}}=2+1$ flavors of $\mathcal{O}(a)$ improved
Wilson fermions. Using two different discretizations of the vector current, we
compute the quark-connected and -disconnected contributions to the hadronic
vacuum polarization (HVP) functions $\bar{\Pi}^{\gamma\gamma}$ and
$\bar{\Pi}^{\gamma Z}$ for Euclidean squared momenta $Q^2\leq
7\,\mathrm{GeV}^2$. Gauge field ensembles at four values of the lattice spacing
and several values of the pion mass, including its physical value, are used to
extrapolate the results to the physical point. The ability to perform an exact
flavor decomposition allows us to present the most precise determination to
date of the $\mathrm{SU}(3)$-flavor-suppressed HVP function $\bar{\Pi}^{08}$
that enters the running of $\sin^2\theta_{\mathrm{W}}$. Our results for
$\bar{\Pi}^{\gamma\gamma}$, $\bar{\Pi}^{\gamma Z}$ and $\bar{\Pi}^{08}$ are
presented in terms of rational functions for continuous values of $Q^2$ below
$7 \,\mathrm{GeV}^2$. We observe a tension of up to $3.5$ standard deviation
between our lattice results for $\Delta\alpha^{(5)}_{\mathrm{had}}(-Q^2)$ and
estimates based on the $R$-ratio for space-like momenta in the range
$3$--$7\,\mathrm{GeV}^2$. The tension is, however, strongly diminished when
translating our result to the $Z$ pole, by employing the Euclidean split
technique and perturbative QCD, which yields
$\Delta\alpha^{(5)}_{\mathrm{had}}(M_Z^2)=0.027\,73(15)$ and agrees with
results based on the $R$-ratio within the quoted uncertainties.
