Searches for new resonances are performed using an unsupervised anomaly-detection technique. Events with at least one electron or muon are selected from 140 fb^{-1} of pp collisions at sqrt[s]=13 TeV recorded by ATLAS at the Large Hadron Collider. The approach involves training an autoencoder on data, and subsequently defining anomalous regions based on the reconstruction loss of the decoder. Studies focus on nine invariant mass spectra that contain pairs of objects consisting of one light jet or b jet and either one lepton (e,μ), photon, or second light jet or b jet in the anomalous regions. No significant deviations from the background hypotheses are observed. Limits on contributions from generic Gaussian signals with various widths of the resonance mass are obtained for nine invariant masses in the anomalous regions.