A search is reported for heavy resonances and quantum black holes decaying into eμ, eτ, and μτ final states in proton-proton collision data recorded by the CMS experiment at the CERN LHC during 2016–2018 at s = 13 TeV, corresponding to an integrated luminosity of 138 fb−1. The eμ, eτ, and μτ invariant mass spectra are reconstructed, and no evidence is found for physics beyond the standard model. Upper limits are set at 95% confidence level on the product of the cross section and branching fraction for lepton flavor violating signals. Three benchmark signals are studied: resonant τ sneutrino production in R parity violating supersymmetric models, heavy Z′ gauge bosons with lepton flavor violating decays, and nonresonant quantum black hole production in models with extra spatial dimensions. Resonant τ sneutrinos are excluded for masses up to 4.2TeV in the eμ channel, 3.7TeV in the eτ channel, and 3.6TeV in the μτ channel. A Z′ boson with lepton flavor violating couplings is excluded up to a mass of 5.0TeV in the eμ channel, up to 4.3Te V in the eτ channel, and up to 4.1TeV in the μτ channel. Quantum black holes in the benchmark model are excluded up to the threshold mass of 5.6TeV in the eμ channel, 5.2TeV in the eτ channel, and 5.0TeV in the μτ channel. In addition, model-independent limits are extracted to allow comparisons with other models for the same final states and similar event selection requirements. The results of these searches provide the most stringent limits available from collider experiments for heavy particles that undergo lepton flavor violating decays. [Figure not available: see fulltext.].