©Open Access. The production of J/ψ mesons with rapidity 1.5 < y < 4.0 or −5.0 < y < −2.5 and transverse momentum pT< 14 GeV/c is studied with the LHCb detector in proton-lead collisions at a nucleon-nucleon centre-of-mass energy √SNN = 5 TeV. The J/ψ mesons are reconstructed using the dimuon decay mode. The analysis is based on a data sample corresponding to an integrated luminosity of about 1.6 nb−1. For the first time the nuclear modification factor and forward-backward production ratio are determined separately for prompt J/ψ mesons and J/ψ from b-hadron decays. Clear suppression of prompt J/ψ production with respect to proton-proton collisions at large rapidity is observed, while the production of J/ψ from b-hadron decays is less suppressed. These results show good agreement with available theoretical predictions. The measurement shows that cold nuclear matter effects are important for interpretations of the related quark-gluon plasma signatures in heavy-ion collisions.