The measurement of Z boson production is presented as a method to determine the integrated luminosity of CMS data sets. The analysis uses proton–proton collision data, recorded by the CMS experiment at the CERN LHC in 2017 at a center-of-mass energy of 13 TeV . Events with Z bosons decaying into a pair of muons are selected. The total number of Z bosons produced in a fiducial volume is determined, together with the identification efficiencies and correlations from the same data set, in small intervals of 20 pb-1 of integrated luminosity, thus facilitating the efficiency and rate measurement as a function of time and instantaneous luminosity. Using the ratio of the efficiency-corrected numbers of Z bosons, the precisely measured integrated luminosity of one data set is used to determine the luminosity of another. For the first time, a full quantitative uncertainty analysis of the use of Z bosons for the integrated luminosity measurement is performed. The uncertainty in the extrapolation between two data sets, recorded in 2017 at low and high instantaneous luminosity, is less than 0.5%. We show that the Z boson rate measurement constitutes a precise method, complementary to traditional methods, with the potential to improve the measurement of the integrated luminosity.