A new algorithm is presented to discriminate reconstructed hadronic decays of tau leptons (τ h) that originate from genuine tau leptons in the CMS detector against τ h candidates that originate from quark or gluon jets, electrons, or muons. The algorithm inputs information from all reconstructed particles in the vicinity of a τ h candidate and employs a deep neural network with convolutional layers to efficiently process the inputs. This algorithm leads to a significantly improved performance compared with the previously used one. For example, the efficiency for a genuine τ h to pass the discriminator against jets increases by 10-30% for a given efficiency for quark and gluon jets. Furthermore, a more efficient τ h reconstruction is introduced that incorporates additional hadronic decay modes. The superior performance of the new algorithm to discriminate against jets, electrons, and muons and the improved τ h reconstruction method are validated with LHC proton-proton collision data at s = 13 TeV.