  A measurement of the effective leptonic weak mixing angle
$\sin^2\theta_\mathrm{eff}^\ell$ is presented using the forward-backward
asymmetry in Drell-Yan dilepton events produced in pp collisions at
$\sqrt{s}=13$ TeV. The data sample corresponds to 137 fb$^{-1}$ of integrated
luminosity and consists of dimuon and dielectron events, including the forward
electrons reconstructed beyond the coverage of the CMS tracking detectors.
Using the CT18Z set of the parton distribution functions (PDF), which provides
the best coverage of the central values extracted with the other global PDFs,
we obtain $$\sin^2\theta^\ell_\mathrm{eff} = 0.23157 \pm 0.00031,$$ where the
total uncertainty includes the statistical uncetainties (0.00010), as well as
the correlated experimental (0.00015), theoretical (0.00009), and PDF (0.00027)
systematic uncertainties. The measured value agrees well with the Standard
Model prediction. This is the most precise measurement at a hadron collider
with comparable precision to the two most precise results obtained at LEP and
SLD.
