Résumé : The production of Z bosons is studied in the dimuon and dielectron decay channels in PbPb and pp collisions at (Formula presented.) TeV, using data collected by the CMS experiment at the LHC. The PbPb data sample corresponds to an integrated luminosity of about 166 μb−1, while the pp data sample collected in 2013 at the same nucleon-nucleon centre-of-mass energy has an integrated luminosity of 5.4 pb−1. The Z boson yield is measured as a function of rapidity, transverse momentum, and collision centrality. The ratio of PbPb to pp yields, scaled by the number of inelastic nucleon-nucleon collisions, is found to be 1.06 ± 0.05 (stat) ± 0.08 (syst) in the dimuon channel and 1.02 ± 0.08 (stat) ± 0.15 (syst) in the dielectron channel, for centrality-integrated Z boson production. This binary collision scaling is seen to hold in the entire kinematic region studied, as expected for a colourless probe that is unaffected by the hot and dense QCD medium produced in heavy ion collisions.