Measurement of Z-boson production in p-Pb collisions at $$ \sqrt{s_{\mathrm{NN}}} $$
s
NN
= 8.16 TeV and Pb-Pb collisions at $$ \sqrt{s_{\mathrm{NN}}} $$
s
NN
= 5.02 TeV is reported. It is performed in the dimuon decay channel, through the detection of muons with pseudorapidity −4 < ημ< −2.5 and transverse momentum $$ {p}_{\mathrm{T}}^{\mu } $$
p
T
μ
> 20 GeV/c in the laboratory frame. The invariant yield and nuclear modification factor are measured for opposite-sign dimuons with invariant mass 60 < mμμ< 120 GeV/c2 and rapidity 2.5 <$$ {y}_{\mathrm{cms}}^{\mu \mu} $$
y
cms
μμ
< 4. They are presented as a function of rapidity and, for the Pb-Pb collisions, of centrality as well. The results are compared with theoretical calculations, both with and without nuclear modifications to the Parton Distribution Functions (PDFs). In p-Pb collisions the center-of-mass frame is boosted with respect to the laboratory frame, and the measurements cover the backward (−4.46 <$$ {y}_{\mathrm{cms}}^{\mu \mu} $$
y
cms
μμ
< −2.96) and forward (2.03 <$$ {y}_{\mathrm{cms}}^{\mu \mu} $$
y
cms
μμ
< 3.53) rapidity regions. For the p-Pb collisions, the results are consistent within experimental and theoretical uncertainties with calculations that include both free-nucleon and nuclear-modified PDFs. For the Pb-Pb collisions, a 3.4σ deviation is seen in the integrated yield between the data and calculations based on the free-nucleon PDFs, while good agreement is found once nuclear modifications are considered.