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 100MeVc2 of the known K∗(892)0 mass. The analysis is performed using proton-proton collision data, corresponding to an integrated luminosity of about 3fb−1, collected by the LHCb experiment at centre-of-mass energies of 7 and 8TeV. The ratio is measured in two regions of the dilepton invariant mass squared, q2, to be \begin{eqnarray*} R_{K^{*0}} = \begin{cases} 0.66~^{+~0.11}_{-~0.07}\mathrm{\,(stat)} \pm 0.03\mathrm{\,(syst)} & \textrm{for } 0.045 < q^{2} < 1.1~\mathrm{\,GeV^2}c^4 \, , \\ 0.69~^{+~0.11}_{-~0.07}\mathrm{\,(stat)} \pm 0.05\mathrm{\,(syst)} & \textrm{for } 1.1\phantom{00} < q^{2} < 6.0~\mathrm{\,GeV^2}c^4 \, . \end{cases} \end{eqnarray*} 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.