A search for narrow resonances in dielectron and dimuon invariant mass spectra has been performed using data obtained from proton–proton collisions at √s=13TeV collected with the CMS detector. The integrated luminosity for the dielectron sample is 2.7 fb−1 and for the dimuon sample 2.9 fb−1. The sensitivity of the search is increased by combining these data with a previously analyzed set of data obtained at √s=8TeV and corresponding to a luminosity of 20 fb−1. No evidence for non-standard-model physics is found, either in the 13 TeV data set alone, or in the combined data set. Upper limits on the product of production cross section and branching fraction have also been calculated in a model-independent manner to enable interpretation in models predicting a narrow dielectron or dimuon resonance structure. Limits are set on the masses of hypothetical particles that could appear in new-physics scenarios. For the ZSSM′ particle, which arises in the sequential standard model, and for the superstring inspired Zψ′ particle, 95% confidence level lower mass limits for the combined data sets and combined channels are found to be 3.37 and 2.82 TeV, respectively. ... mehrThe corresponding limits for the lightest Kaluza–Klein graviton arising in the Randall–Sundrum model of extra dimensions with coupling parameters 0.01 and 0.10 are 1.46 and 3.11 TeV, respectively. These results significantly exceed the limits based on the 8 TeV LHC data.