A search for dark matter particles is performed using events with a Z boson candidate and large missing transverse momentum. The analysis is based on proton–proton collision data at a center-of-mass energy of 13Te, collected by the CMS experiment at the LHC in 2016–2018, corresponding to an integrated luminosity of 137fb-1. The search uses the decay channels Z → e e and Z → μ μ. No significant excess of events is observed over the background expected from the standard model. Limits are set on dark matter particle production in the context of simplified models with vector, axial-vector, scalar, and pseudoscalar mediators, as well as on a two-Higgs-doublet model with an additional pseudoscalar mediator. In addition, limits are provided for spin-dependent and spin-independent scattering cross sections and are compared to those from direct-detection experiments. The results are also interpreted in the context of models of invisible Higgs boson decays, unparticles, and large extra dimensions.