Direct searches for lepton flavor violation in decays of the Z boson with the ATLAS detector at the LHC are presented. Decays of the Z boson into an electron or muon and a hadronically decaying τ lepton are considered. The searches are based on a data sample of proton-proton collisions collected by the ATLAS detector in 2015 and 2016, corresponding to an integrated luminosity of 36.1 fb-1 at a center-of-mass energy of s=13 TeV. No statistically significant excess of events above the expected background is observed, and upper limits on the branching ratios of lepton-flavor-violating decays are set at the 95% confidence level: B(Z→eτ)<5.8×10-5 and B(Z→μτ)<2.4×10-5. This is the first limit on B(Z→eτ) with ATLAS data. The upper limit on B(Z→μτ) is combined with a previous ATLAS result based on 20.3 fb-1 of proton-proton collision data at a center-of-mass energy of s=8 TeV and the combined upper limit at 95% confidence level is B(Z→μτ)<1.3×10-5.