The measurement of the luminosity recorded by the CMS detector installed at LHC interaction point 5, using proton-proton collisions at s=13TeV in 2015 and 2016, is reported. The absolute luminosity scale is measured for individual bunch crossings using beam-separation scans (the van der Meer method), with a relative precision of 1.3 and 1.0% in 2015 and 2016, respectively. The dominant sources of uncertainty are related to residual differences between the measured beam positions and the ones provided by the operational settings of the LHC magnets, the factorizability of the proton bunch spatial density functions in the coordinates transverse to the beam direction, and the modeling of the effect of electromagnetic interactions among protons in the colliding bunches. When applying the van der Meer calibration to the entire run periods, the integrated luminosities when CMS was fully operational are 2.27 and 36.3 fb-1 in 2015 and 2016, with a relative precision of 1.6 and 1.2%, respectively. These are among the most precise luminosity measurements at bunched-beam hadron colliders.