A search is presented for new high-mass resonances decaying into electron or muon pairs. The search uses proton-proton collision data at a centre-of-mass energy of 13 TeV collected by the CMS experiment at the LHC in 2016, corresponding to an integrated luminosity of 36 fb−1. Observations are in agreement with standard model expectations. Upper limits on the product of a new resonance production cross section and branching fraction to dileptons are calculated in a model-independent manner. This permits the interpretation of the limits in models predicting a narrow dielectron or dimuon resonance. A scan of different intrinsic width hypotheses is performed. Limits are set on the masses of various hypothetical particles. For the Z′ SSM (Z′ ψ) particle, which arises in the sequential standard model (superstring-inspired model), a lower mass limit of 4.50 (3.90) TeV is set at 95% confidence level. The lightest Kaluza-Klein graviton arising in the Randall-Sundrum model of extra dimensions, with coupling parameters k/MPl of 0.01, 0.05, and 0.10, is excluded at 95% confidence level below 2.10, 3.65, and 4.25 TeV, respectively. In a simplified model of dark matter production via a vector or axial vector mediator, limits at 95% confidence level are obtained on the masses of the dark matter particle and its mediator.