The production of prompt Λc+ baryons is measured via the exclusive decay channel Λc+→pK−π+ at a center-of-mass energy per nucleon pair of 5.02 TeV, using proton-proton (pp) and lead-lead (PbPb) collision data collected by the CMS experiment at the CERN LHC. The pp and PbPb data were obtained in 2017 and 2018 with integrated luminosities of 252 and 0.607 nb−1, respectively. The measurements are performed within the Λc+ rapidity interval |y| < 1 with transverse momentum (pT) ranges of 3–30 and 6–40 GeV/c for pp and PbPb collisions, respectively. Compared to the yields in pp collisions scaled by the expected number of nucleon-nucleon interactions, the observed yields of Λc+ with pT> 10 GeV/c are strongly suppressed in PbPb collisions. The level of suppression depends significantly on the collision centrality. The Λc+/D0 production ratio is similar in PbPb and pp collisions at pT> 10 GeV/c, suggesting that the coalescence process does not play a dominant role in prompt Λc+ baryon production at higher pT.