A search for heavy resonances decaying into a pair of Z bosons leading to ℓ+ℓ−ℓ′+ℓ′− and ℓ+ℓ−νν¯ final states, where ℓ stands for either an electron or a muon, is presented. The search uses proton–proton collision data at a centre-of-mass energy of 13 TeV collected from 2015 to 2018 that corresponds to the integrated luminosity of 139 fb−1 recorded by the ATLAS detector during Run 2 of the Large Hadron Collider. Different mass ranges spanning 200 GeV to 2000 GeV for the hypothetical resonances are considered, depending on the final state and model. In the absence of a significant observed excess, the results are interpreted as upper limits on the production cross section of a spin-0 or spin-2 resonance. The upper limits for the spin-0 resonance are translated to exclusion contours in the context of Type-I and Type-II two-Higgs-doublet models, and the limits for the spin-2 resonance are used to constrain the Randall–Sundrum model with an extra dimension giving rise to spin-2 graviton excitations.