Abstract: The transverse momentum (pT) distributions of ?, ??, and ?? baryons, their antiparticles, and K0S mesons are measured in proton-proton (pp) and proton-lead (pPb) collisions at a nucleon-nucleon center-of-mass energy of 5.02 TeV over a broad rapidity range. The data, corresponding to integrated luminosities of 40.2 nb-1 and 15.6 ?b-1 for pp and pPb collisions, respectively, were collected by the CMS experiment. The nuclear modification factor RpPb, which is defined as the ratio of the particle yield in pPb collisions and a scaled pp reference, is measured for each particle. A strong dependence on particle species is observed in the pT range from 2 to 7 GeV, where RpPb for K0S is consistent with unity, while an enhancement ordered by strangeness content and/or particle mass is observed for the three baryons. In pPb collisions, the strange hadron production is asymmetric about the nucleon-nucleon center-of-mass rapidity. Enhancements, which depend on the particle type, are observed in the direction of the Pb beam. The results are compared with predictions from EPOS LHC, which includes parametrized radial flow. The model is in qualitative agreement with the RpPb data, but fails to describe the dependence on particle species in the yield asymmetries measured away from midrapidity in pPb collisions.