The ratio of branching fractions of the decays Λb0 → pK−e+e− and Λb0 → pK−μ+μ−,RpK−1, is measured for the first time using proton-proton collision data corresponding to an integrated luminosity of 4.7 fb−1 recorded with the LHCb experiment at center-of-mass energies of 7, 8 and 13 TeV. In the dilepton mass-squared range 0.1 < q2< 6.0 GeV2/c4 and the pK− mass range m(pK−) < 2600 MeV/c2, the ratio of branching fractions is measured to be RpK−1=1.17−0.16+0.18±0.07, where the first uncertainty is statistical and the second systematic. This is the first test of lepton universality with b baryons and the first observation of the decay Λb0 → pK−e+e−. [Figure not available: see fulltext.].