Four-lepton production in proton-proton collisions, p p → (Z / γ∗) (Z / γ∗) → 4 ℓ, where ℓ= e or μ, is studied at a center-of-mass energy of 13TeV with the CMS detector at the LHC. The data sample corresponds to an integrated luminosity of 35.9fb-1. The ZZ production cross section, σ(pp→ZZ)=17.2±0.5(stat)±0.7(syst)±0.4(theo)±0.4(lumi) pb, measured using events with two opposite-sign, same-flavor lepton pairs produced in the mass region 60<mℓ+ℓ-<120GeV, is consistent with standard model predictions. Differential cross sections are measured and are well described by the theoretical predictions. The Z boson branching fraction to four leptons is measured to be B(Z=4.8±0.2(stat)±0.2(syst)±0.1(theo)±0.1(lumi)×10-6 for events with a four-lepton invariant mass in the range 80<m4ℓ<100GeV and a dilepton mass m4GeV for all opposite-sign, same-flavor lepton pairs. The results agree with standard model predictions. The invariant mass distribution of the four-lepton system is used to set limits on anomalous ZZZ and ZZγ couplings at 95% confidence level: -0.0012<f4Z<0.0010, -0.0010<f5Z<0.0013, -0.0012<f4γ<0.0013, -0.0012<f5γ<0.0013.