Precision luminosity calibration is critical to determine fundamental parameters of the standard model and to constrain or to discover beyond-the-standard-model phenomena at LHC. The luminosity determination at the LHC interaction point 5 with the CMS detector, using proton-proton collisions at 13 and 5.02 TeV during Run 2 of the LHC (2015–2018), is reported. The absolute luminosity scale is obtained using beam-separation (``van der Meer'') scans. The dominant sources of systematic uncertainty are related to the knowledge of the scale of the beam separation provided by LHC magnets and the nonfactorizability between the spatial components of the proton bunch density distributions in the transverse direction. When applying the van der Meer calibration to the entire data-taking period, a substantial contribution to the total uncertainty in the integrated luminosity originates from the measurement of the detector linearity and stability. The reported integrated luminosity in 2015–2016 is among the most precise luminosity measurements at bunched-beam hadron colliders.