A search for nonresonant excesses in the invariant mass spectra of electron and muon pairs is presented. The analysis is based on data from proton-proton collisions at a center-of-mass energy of 13 TeV recorded by the CMS experiment in 2016, corresponding to a total integrated luminosity of 36 fb(-1). No significant deviation from the standard model is observed. Limits are set at 95% confidence level on energy scales for two general classes of nonresonant models. For a class of fermion contact interaction models, lower limits ranging from 20 to 32 TeV are set on the characteristic compositeness scale . For the Arkani-Hamed, Dimopoulos, and Dvali model of large extra dimensions, the first results in the dilepton final state at 13 TeV are reported, and values of the ultraviolet cutoff parameter (T) below 6.9 TeV are excluded. A combination with recent CMS diphoton results improves this exclusion to (T) below 7.7 TeV, providing the most sensitive limits to date in nonhadronic final states.