We model the interaction between the wind from a newly formed rapidly rotating magnetar and the surrounding progenitor. in the first few seconds after core collapse the magnetar inflates a bubble of plasma and magnetic fields behind the supernova shock, which expands asymmetrically because of the pinching effect of the toroidal magnetic field, as in PWNe, even if the host star is spherically symmetric. The degree of asymmetry depends on the ratio of the magnetic energy to the total energy in the bubble.We assume that the wind by newly formed magnetars inflating these bubbles is more magnetized than for PWNe.We show that for a magnetic to total power supplied by the central magnetar ∼ 0.1 the bubble expands relatively spherically while for values greater than 0.3, most of the pressure in the bubble is exerted close to the rotation axis, driving a collimated outflow out through the host star. This can account for the collimation inferred from observations of long-duration gamma-ray bursts (GRBs). Given that the wind magnetization increases in time, we thus suggest that the magnetar-driven bubble initially expands relatively spherically (enhancing the energy of the associated supernova) while at late times it becomes progressively more collimated (producing the GRB). Similar processes may operate in more modestly rotating neutron stars to produce asymmetric supernovae and lower energy transients such as X-ray flashes.