A search for heavy neutral gauge bosons (𝑍′) decaying into a pair of tau leptons is performed in proton-proton collisions at √𝑠 =13 TeV at the CERN LHC. The data were collected with the CMS detector and correspond to an integrated luminosity of 138 fb−1. The observations are found to be in agreement with the expectation from standard model processes. Limits at 95% confidence level are set on the product of the 𝑍′ production cross section and its branching fraction to tau lepton pairs for a range of 𝑍′ boson masses. For a narrow resonance in the sequential standard model scenario, a 𝑍′ boson with a mass below 3.5 TeV is excluded. This is the most stringent limit to date from this type of search.