A study of anomalous couplings of the Higgs boson to vector bosons and fermions is presented. The data were recorded by the CMS experiment at a center-of-mass energy of pp collisions at the LHC of 13 TeV and correspond to an integrated luminosity of 138 fb - 1 . The study uses Higgs boson candidates produced mainly in gluon fusion or electroweak vector boson fusion at the LHC that subsequently decay to a pair of τ leptons. Matrix-element and machine-learning techniques were employed in a search for anomalous interactions. The results are combined with those from the four-lepton and two-photon decay channels to yield the most stringent constraints on anomalous Higgs boson couplings to date. The pure C P -odd scenario of the Higgs boson coupling to gluons is excluded at 2.4 standard deviations. The results are consistent with the standard model predictions.