Image copyright NASA Image caption Magnetic flux ropes (shown right) are at the heart of eruptions from the Sun

Scientists may finally understand the mechanism behind solar flares.

Flares can occur on their own, or be accompanied by powerful eruptions of plasma (charged gas) from the Sun.

If charged particles from these eruptions reach Earth, they can create havoc with infrastructure, such as satellite systems and power grids.

Now, researchers in France say the interaction of distinct magnetic structures controls these outbursts from our star.

Generally speaking, solar eruptions are caused by a sudden, violent rearrangement of the Sun's magnetic field.

At a deeper level, the process is controlled by two types of structures that form in the magnetic field of the Sun: ropes and cages.

The rope is confined within the magnetic cage. If the cage is strong, it can contain the rope's contortions, but when the cage is weak, an eruption of plasma known as a coronal mass ejection (CME) can take place.

Image copyright Tahar Amari et al / CNRS-Ecole Polytechnique Image caption The rope is confined within a magnetic cage structure; its strength determines whether a coronal mass ejection occurs

"The important point is that we got information on something we didn't expect to be playing an important role. That was the cage above the rope," Dr Tahar Amari, from École polytechnique and the CNRS in France, told BBC News.

The researchers focused on an intense flare that developed over a few hours on 24 October 2014.

Flares are spawned in the Sun's corona, the outermost layer of its atmosphere. But, for reasons that remain unclear, the corona is much hotter than the surface, inhibiting scientists' ability to study the magnetic field here.

Instead, the researchers used data from the photosphere - the Sun's "surface" - to reconstruct what was going on 1,690km above in the corona.

Using data from Nasa's Solar Dynamics Observatory (SDO) spacecraft, the researchers ran simulations on supercomputers.

Image copyright Tahar Amari et al / CNRS-Ecole Polytechnique Image caption The rope can become twisted, leading to the kind of instability that partially destroyed the cage in the event on 24 October 2014

They found that the rope had insufficient energy to break through all the layers of the cage, snuffing out the possibility of a CME. Despite this, the rope became highly twisted, which triggered a magnetic instability, destroying part of the cage. This allowed a powerful blast of radiation to break through, disrupting technology on Earth.

Using their method, the researchers have developed a model able to predict the maximum energy that could be released from the region of the Sun concerned. The model showed that for the 2014 eruption, a huge ejection of plasma would have occurred if the cage had been less resistant.

The work could be put to use in forecasting, to provide early warning of solar eruptions that could cause geomagnetic storms here on Earth that threaten infrastructure.

"We're working on using it... you have to face practical issues. One practical issue is timescale. If you want to be very fast (in predicting events), you have to accept being less accurate," said Dr Amari.

Dr Amari is involved in a project to understand the origin and propagation of CMEs through space, in an effort to improve predictions.

Follow Paul on Twitter.