The top quark pair production cross section (stt) is measured in pp collisions at a center-of-mass energy of 5.02 TeV. The analyzed data have been collected by the CMS experiment at the CERN LHC and correspond to an integrated luminosity of 27.4 /pb. The measurement is performed by analyzing events with at least one charged lepton. The measured cross section is 69.5 +/- 8.4 pb. The result is in agreement with the expectation from the standard model. The impact of the presented measurement on the gluon distribution function is illustrated through a quantum chromodynamic analysis at next-to-next-to-leading order.