We use ideal axisymmetric relativistic magnetohydrodynamic simulations to calculate the spin-down of a newly formed millisecond, B∼ 1015 G, magnetar and its interaction with the surrounding stellar envelope during a core-collapse supernova (SN) explosion. The mass, angular momentum and rotational energy lost by the neutron star are determined self-consistently given the thermal properties of the cooling neutron star's atmosphere and the wind's interaction with the surrounding star. The magnetar drives a relativistic magnetized wind into a cavity created by the outgoing SN shock. For high spin-down powers (∼1051–1052 erg s−1), the magnetar wind is superfast at almost all latitudes, while for lower spin-down powers (∼1050 erg s−1), the wind is subfast but still super-Alfvénic. In all cases, the rates at which the neutron star loses mass, angular momentum and energy are very similar to the corresponding free wind values (≲30 per cent differences), in spite of the causal contact between the neutron star and the stellar envelope. In addition, in all cases that we consider, the magnetar drives a collimated (∼5–10°) relativistic jet out along the rotation axis of the star. Nearly all of the spin-down power of the neutron star escapes via this polar jet, rather than being transferred to the more spherical SN explosion. The properties of this relativistic jet and its expected late-time evolution in the magnetar model are broadly consistent with observations of long duration gamma-ray bursts (GRBs) and their associated broad-lined Type Ic SN.