A test of lepton universality, performed by measuring the ratio of the branching fractions of the B0 → K*0μ+μ− and B0 → K*0e+e− decays, RK*0, is presented. The K*0 meson is reconstructed in the final state K+π−, which is required to have an invariant mass within 100 MeV/c2 of the known K*(892)0 mass. The analysis is performed using proton-proton collision data, corresponding to an integrated luminosity of about 3 fb−1, collected by the LHCb experiment at centre-of-mass energies of 7 and 8 TeV. The ratio is measured in two regions of the dilepton invariant mass squared, q2, to be (Formula presented.) The corresponding 95.4% confidence level intervals are [0.52, 0.89] and [0.53, 0.94]. The results, which represent the most precise measurements of RK*0 to date, are compatible with the Standard Model expectations at the level of 2.1–2.3 and 2.4–2.5 standard deviations in the two q2 regions, respectively.[Figure not available: see fulltext.].