A search for new phenomena is presented in final states with two leptons and one or no b-tagged jets. The event selection requires the two leptons to have opposite charge, the same flavor (electrons or muons), and a large invariant mass. The analysis is based on the full run-2 proton-proton collision dataset recorded at a center-of-mass energy of s=13 TeV by the ATLAS experiment at the LHC, corresponding to an integrated luminosity of 139 fb-1. No significant deviation from the expected background is observed in the data. Inspired by the B-meson decay anomalies, a four-fermion contact interaction between two quarks (b, s) and two leptons (ee or μμ) is used as a benchmark signal model, which is characterized by the energy scale and coupling, Λ and g∗, respectively. Contact interactions with Λ/g∗ lower than 2.0 (2.4) TeV are excluded for electrons (muons) at the 95% confidence level, still far below the value that is favored by the B-meson decay anomalies. Model-independent limits are set as a function of the minimum dilepton invariant mass, which allow the results to be reinterpreted in various signal scenarios.