Yields of prompt and non-prompt J/ψ, as well as Υ(1S) mesons, are measured by the CMS experiment via their µ + µ − decays in PbPb and pp collisions at √ s NN = 2.76 TeV for quarkonium rapidity |y| < 2.4. Differential cross sections and nuclear modification factors are reported as functions of y and transverse momentum p T , as well as collision centrality. For prompt J/ψ with relatively high p T (6.5 < p T < 30 GeV/c), a strong, centrality-dependent suppression is observed in PbPb collisions, compared to the yield in pp collisions scaled by the number of inelastic nucleon-nucleon collisions. In the same kinematic range, a suppression of non-prompt J/ψ, which is sensitive to the in-medium b-quark energy loss, is measured for the first time. Also the low-p T Υ(1S) mesons are suppressed in PbPb collisions.