A precision measurement of the $Z$ boson production cross-section at $\sqrt{s} = 13$ TeV in the forward region is presented, using $pp$ collision data collected by the LHCb detector, corresponding to an integrated luminosity of 5.1 fb$^{-1}$. The production cross-section is measured using $Z\rightarrow\mu^+\mu^-$ events within the fiducial region defined as pseudorapidity $2.0<\eta<4.5$ and transverse momentum $p_{T}>20$ GeV/$c$ for both muons and dimuon invariant mass $60<M_{\mu\mu}<120$ GeV/$c^2$. The integrated cross-section is determined to be $\sigma (Z \rightarrow \mu^+ \mu^-)$ = 196.4 $\pm$ 0.2 $\pm$ 1.6 $\pm$ 3.9~pb, where the first uncertainty is statistical, the second is systematic, and the third is due to the luminosity determination. The measured results are in agreement with theoretical predictions within uncertainties.
The double differential cross sections of the Drell-Yan lepton pair ($\ell^+\ell^-$, dielectron or dimuon) production are measured as functions of the invariant mass $m_{\ell\ell}$, transverse momentum $p_\mathrm{T}(\ell\ell)$, and $\phi^*_\eta$. The $\phi^*_\eta$ observable, derived from angular measurements of the leptons and highly correlated with $p_\mathrm{T}(\ell\ell)$, is used to probe the low-$p_\mathrm{T}(\ell\ell)$ region in a complementary way. Dilepton masses up to 1 TeV are investigated. Additionally, a measurement is performed requiring at least one jet in the final state. To benefit from partial cancellation of the systematic uncertainty, the ratios of the differential cross sections for various $m_{\ell\ell}$ ranges to those in the Z mass peak interval are presented. The collected data correspond to an integrated luminosity of 36.3 fb$^{-1}$ of proton-proton collisions recorded with the CMS detector at the LHC at a centre-of-mass energy of 13 TeV. Measurements are compared with predictions based on perturbative quantum chromodynamics, including soft-gluon resummation.