The production of jets in association with Z bosons, reconstructed via the mu(+)mu(-) and e(+)e(-) decay channels, is studied in pp and, for the first time, in Pb-Pb collisions. Both data samples were collected by the CMS experiment at the LHC, at a nucleon-nucleon center-of-mass energy of 5.02 TeV. The Pb-Pb collisions were analyzed in the 0%-30% centrality range. The back-to-back azimuthal alignment was studied in both pp and Pb-Pb collisions for Z bosons with transverse momentum p(T)(Z) > 60 GeV/c and a recoiling jet with p(T)(jet) > 30 GeV/c. The p(T) imbalance x(jZ) = p(T)(jet)/p(T)(Z), as well as the average number of jet partners per Z, R-jZ, was studied in intervals of p(T)(Z). The R-jZ is found to be smaller in Pb-Pb than in pp collisions, which suggests that in Pb-Pb collisions a larger fraction of partons associated with the Z bosons fall below the 30 GeV/c p(T)(jet) threshold because they lose energy.