We present an observation of photon-photon production of τ lepton pairs in ultraperipheral lead-lead collisions. The measurement is based on a data sample with an integrated luminosity of 404 μb−1 collected by the CMS experiment at a center-of-mass energy per nucleon pair of √sNN=5.02 TeV. The γγ→τ+τ− process is observed for τ+τ− events with a muon and three charged hadrons in the final state. The measured fiducial cross section is σ(γγ→τ+τ−)=4.8±0.6(stat)±0.5(syst) μb, where the second (third) term corresponds to the statistical (systematic) uncertainty in σ(γγ→τ+τ−) in agreement with leading-order QED predictions. Using σ(γγ→τ+τ−), we estimate a model-dependent value of the anomalous magnetic moment of the τ lepton of aτ=0.001+0.055−0.089.