A test of lepton universality between muons and electrons is performed using B + → K + ℓ + ℓ − decays (where ℓ = e, μ), in the dilepton invariant-mass-squared region above 14.3 GeV2 /c 4. The data used for the measurement consists of beauty meson decays produced in proton-proton collisions, corresponding to an integrated luminosity of 9 fb −1, collected by the LHCb experiment between 2011 and 2018. The ratio of branching fractions for B + → K + μ + μ − and B + → K + e + e − decays is measured to be , which is consistent with the Standard Model prediction of unity. This constitutes the most precise test of lepton flavour universality using B + → K + ℓ + ℓ − decays with dilepton invariant-mass-squared above the ψ(2S) mass, whilst being the first of its kind at a hadron collider.