This paper describes a measurement of light-by-light scattering based on Pb+Pb collision data recorded by the ATLAS experiment during Run 2 of the LHC. The study uses 2.2 nb−1 of integrated luminosity collected in 2015 and 2018 at $$ \sqrt{s_{\mathrm{NN}}} $$
s
NN
= 5.02 TeV. Light-by-light scattering candidates are selected in events with two photons produced exclusively, each with transverse energy $$ {E}_{\mathrm{T}}^{\gamma } $$
E
T
γ
> 2.5 GeV, pseudorapidity |ηγ| < 2.37, diphoton invariant mass mγγ> 5 GeV, and with small diphoton transverse momentum and diphoton acoplanarity. The integrated and differential fiducial cross sections are measured and compared with theoretical predictions. The diphoton invariant mass distribution is used to set limits on the production of axion-like particles. This result provides the most stringent limits to date on axion-like particle production for masses in the range 6–100 GeV. Cross sections above 2 to 70 nb are excluded at the 95% CL in that mass interval.