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. The measurements are performed by targeting final states with three or four isolated leptons (electrons or muons) and are based on $\sqrt{s}=13$ TeV proton-proton collision data with an integrated luminosity of $139\,\text{fb}^{-1}$, recorded from 2015 to 2018 with the ATLAS detector at the CERN Large Hadron Collider. The inclusive cross section is measured to be $$\sigma_{t\bar{t}Z} = 0.99 \pm 0.05\,\text{(stat.)} \pm 0.08\,\text{(syst.)}\,\text{pb},$$ in agreement with the most precise theoretical predictions. The differential measurements are presented as a function of a number of kinematic variables which probe the kinematics of the $t\bar{t}Z$ system. Both absolute and normalised differential cross-section measurements are performed at particle and parton levels for specific fiducial volumes and are compared with theoretical predictions at different levels of precision, based on a $\chi^2$/ndf and $p$-value computation. Overall, good agreement is observed between the unfolded data and the predictions.