When a magnetically dominated superfast-magnetosonic long/soft gamma-ray burst (GRB) jet leaves the progenitor star, the external pressure support will drop and the jet may enter the regime of ballistic expansion, during which additional magnetic acceleration becomes ineffective. However, recent numerical simulations by Tchekhovskoy et al. have suggested that the transition to this regime is accompanied by a spurt of acceleration. We confirm this finding numerically and attribute the acceleration to a sideways expansion of the jet, associated with a strong magnetosonic rarefaction wave that is driven into the jet when it loses pressure support, which induces a conversion of magnetic energy into kinetic energy of bulk motion. This mechanism, which we dub rarefaction acceleration, can only operate in a relativistic outflow because in this case the total energy can still be dominated by the magnetic component even in the superfast-magnetosonic regime. We analyse this process using the equations of relativistic magnetohydrodynamics and demonstrate that it is more efficient at converting internal energy into kinetic energy when the flow is magnetized than in a purely hydrodynamic outflow, as was found numerically by Mizuno et al. We show that, just as in the case of the magnetic acceleration of a collimating jet that is confined by an external pressure distribution - the collimation-acceleration mechanism - the rarefaction-acceleration process in a magnetized jet is a consequence of the fact that the separation between neighbouring magnetic flux surfaces increases faster than their cylindrical radius. However, whereas in the case of effective collimation-acceleration the product of the jet opening angle and its Lorentz factor does not exceed ~1, the addition of the rarefaction-acceleration mechanism makes it possible for this product to become >>1, in agreement with the inference from late-time panchromatic breaks in the afterglow light curves of long/soft GRBs.