Measurements of both the inclusive and differential production cross sections of a top-quark-antiquark pair in association with a Z boson ($t\bar{t}Z$) are presented. Final states with two, three and four isolated leptons (electrons or muons) are targeted. The measurements use the data recorded by the ATLAS detector in pp collisions at $\sqrt{s}=13$ TeV at the Large Hadron Collider during the years 2015-2018, corresponding to an integrated luminosity of 140 fb$^{-1}$. The inclusive cross section is measured to be $\sigma_{t\bar{t}Z}=0.86\pm 0.04(\text{stat.})\pm 0.04(\text{syst.})$ pb and found to be in agreement with the most advanced Standard Model predictions. The differential measurements are presented as a function of a number of observables that probe the kinematics of the $t\bar{t}Z$ system. Both absolute and normalised differential cross section measurements are performed at particle- and parton-level for specific fiducial volumes, and are compared with theoretical predictions at NLO+NNLL. The results are interpreted in the framework of the Standard Model Effective Field Theory and used to set limits on a large number of dimension-6 operators involving the top quark. The first measurement of spin correlations in $t\bar{t}Z$ is presented: the results are in agreement with the Standard Model expectations, and the null hypothesis of no spin correlations is disfavoured with a significance of 1.8 standard deviations.