This Letter reports the observation of τ-lepton-pair production in ultraperipheral lead-lead collisions Pb+Pb→Pb(γγ→ττ)Pb and constraints on the τ-lepton anomalous magnetic moment aτ. The dataset corresponds to an integrated luminosity of 1.44 nb−1 of LHC Pb+Pb collisions at √sNN=5.02 TeV recorded by the ATLAS experiment in 2018. Selected events contain one muon from a τ-lepton decay, an electron or charged-particle track(s) from the other τ-lepton decay, little additional central-detector activity, and no forward neutrons. The γγ→ττ process is observed in Pb+Pb collisions with a significance exceeding 5 standard deviations and a signal strength of μττ= assuming the standard model value for aτ. To measure aτ, a template fit to the muon transverse-momentum distribution from τ-lepton candidates is performed, using a dimuon (γγ→μμ) control sample to constrain systematic uncertainties. The observed 95% confidence-level interval for aτ is −0.057<aτ<0.024.