Measurements are presented of the differential cross sections for Z bosons produced in proton-proton collisions at 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 pT, the optimized angular variable ϕη∗, 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 ϕη∗< 0.5 and for pTZ< 50 GeV. [Figure not available: see fulltext.]