  This Letter reports the observation of $\tau$-lepton pair production in
ultraperipheral lead-lead collisions, $\text{Pb+Pb} \to \text{Pb}(\gamma\gamma
\to \tau\tau)\text{Pb}$, and constraints on the $\tau$-lepton anomalous
magnetic moment, $a_\tau$. The dataset corresponds to an integrated luminosity
of 1.44 nb$^{-1}$ of LHC Pb+Pb collisions at $\sqrt{s_{_\text{NN}}} = 5.02$ TeV
recorded by the ATLAS experiment in 2018. Selected events contain one muon from
a $\tau$-lepton decay, an electron or charged-particle track(s) from the other
$\tau$-lepton decay, little additional central-detector activity, and no
forward neutrons. The $\gamma\gamma \to \tau\tau$ process is observed in Pb+Pb
collisions with a significance exceeding 5 standard deviations, and a signal
strength of $\mu_{\tau\tau} = 1.03^{+0.06}_{-0.05}$ assuming the Standard Model
value for $a_\tau$. To measure $a_\tau$, a template fit to the muon
transverse-momentum distribution from $\tau$-lepton candidates is performed,
using a dimuon ($\gamma\gamma \to \mu\mu$) control sample to constrain
systematic uncertainties. The observed 95% confidence-level interval for
$a_\tau$ is $-0.057 < a_\tau < 0.024$.
