A search for the electroweak production of supersymmetric particles in proton-proton collisions at a center-of-mass energy of 13 TeV is presented in final states with a τ lepton pair. Both hadronic and leptonic decay modes are considered for the τ leptons. Scenarios involving the direct pair production of τ sleptons, or their indirect production via the decays of charginos and neutralinos, are investigated. The data correspond to an integrated luminosity of 35.9 fb−1 collected with the CMS detector in 2016. The observed number of events is consistent with the standard model background expectation. The results are interpreted as upper limits on the cross section for τ slepton pair production in different scenarios. The strongest limits are observed in the scenario of a purely left-handed low mass τ slepton decaying to a nearly massless neutralino. Exclusion limits are also set in the context of simplified models of chargino-neutralino and chargino pair production with decays to τ leptons, and range up to 710 and 630 GeV, respectively.[Figure not available: see fulltext.].