The first measurement of the Z boson production cross-section at centre-of-mass energy s = 5.02 TeV in the forward region is reported, using pp collision data collected by the LHCb experiment in year 2017, corresponding to an integrated luminosity of 100 ± 2 pb−1. The production cross-section is measured for final-state muons in the pseudorapidity range 2.0 < η < 4.5 with transverse momentum pT> 20 GeV/c. The integrated cross-section is determined to be (Formula presented.) for the di-muon invariant mass in the range 60 < Mμμ< 120 GeV/c2. This result and the differential cross-section results are in good agreement with theoretical predictions at next-to-next-to-leading order in the strong coupling constant. Based on a previous LHCb measurement of the Z boson production cross-section in pPb collisions at sNN = 5.02 TeV, the nuclear modification factor RpPb is measured for the first time at this energy. The measured values are 1.2−0.3+0.5 (stat) ± 0.1(syst) in the forward region (1.53