The production of Z bosons in pPb collisions at √sNN=5.02 TeV is studied by the CMS experiment via the electron and muon decay channels. The inclusive cross section is compared to pp collision predictions, and found to scale with the number of elementary nucleon–nucleon collisions. The differential cross sections as a function of the Z boson rapidity and transverse momentum are measured. Though they are found to be consistent within uncertainty with theoretical predictions both with and without nuclear effects, the forward–backward asymmetry suggests the presence of nuclear effects at large rapidities. These results provide new data for constraining nuclear parton distribution functions.