  The ideal helical kink instability of a force-free coronal magnetic flux
rope, anchored in the photosphere, is studied as a model for solar eruptions.
Using the flux rope model of Titov & Demoulin (1999} as the initial condition
in MHD simulations, both the development of helical shape and the rise profile
of a confined (or failed) filament eruption (on 2002 May 27) are reproduced in
very good agreement with the observations. By modifying the model such that the
magnetic field decreases more rapidly with height above the flux rope, a full
(or ejective) eruption of the rope is obtained in very good agreement with the
developing helical shape and the exponential-to-linear rise profile of a fast
coronal mass ejection (CME) (on 2001 May 15). This confirms that the helical
kink instability of a twisted magnetic flux rope can be the mechanism of the
initiation and the initial driver of solar eruptions. The agreement of the
simulations with properties that are characteristic of many eruptions suggests
that they are often triggered by the kink instability. The decrease of the
overlying field with height is a main factor in deciding whether the
instability leads to a confined event or to a CME.
