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 sqrt[s_{NN}]=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 μ_{ττ}=1.03_{-0.05}^{+0.06} 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.