  Measurements are presented of the differential cross sections for Z bosons
produced in proton-proton collisions at $\sqrt{s} =$ 13 TeV and decaying to
muons and electrons. The data analyzed were collected in 2016 with the CMS
detector at the LHC and correspond to an integrated luminosity of 35.9
fb$^{-1}$. The measured fiducial inclusive product of cross section and
branching fraction agrees with next-to-next-to-leading order quantum
chromodynamics calculations. Differential cross sections of the transverse
momentum $p_\mathrm{T}$, the optimized angular variable $\phi^*_\eta$, and the
rapidity of lepton pairs are measured. The data are corrected for detector
effects and compared to theoretical predictions using fixed order, resummed,
and parton shower calculations. The uncertainties of the measured normalized
cross sections are smaller than 0.5% for $\phi^*_\eta$ $<$ 0.5 and for
$p_\mathrm{T}^\mathrm{Z}$ $<$ 50 GeV.
