Aims. We present the analysis of the gravitational microlensing event OGLE-2011-BLG-0251. This anomalous event was observed by several survey and follow-up collaborations conducting microlensing observations towards the Galactic bulge. Methods. Based on detailed modelling of the observed light curve, we find that the lens is composed of two masses with a mass ratio q = 1.9 × 10-3. Thanks to our detection of higher-order effects on the light curve due to the Earth's orbital motion and the finite size of source, we are able to measure the mass and distance to the lens unambiguously. Results. We find that the lens is made up of a planet of mass 0.53 ± 0.21 M J orbiting an M dwarf host star with a mass of 0.26 ± 0.11 M⊙. The planetary system is located at a distance of 2.57 ± 0.61 kpc towards the Galactic centre. The projected separation of the planet from its host star is d = 1.408 ± 0.019, in units of the Einstein radius, which corresponds to 2.72 ± 0.75 AU in physical units. We also identified a competitive model with similar planet and host star masses, but with a smaller orbital radius of 1.50 ± 0.50 AU. The planet is therefore located beyond the snow line of its host star, which we estimate to be around ~1-1.5 AU. © 2013 ESO.