It took just five seconds. At 12.32pm Madrid time, all was well with Spain’s grid. It was a sunny day, and the vast majority of its electricity was from renewables.

Then, at 12.33pm, there was a loss of power in the south. The rest of the grid took up the slack — the system worked.

However, a second and a half later, there was another loss. Three and a half seconds after that, something caused the interconnector with France to be cut.

There had been, the grid operator said, a “very strong oscillation” and by 12.40pm the entire Iberian network had collapsed. A major European economy had effectively ceased to run.

Why? And might it have been made worse — as some are now claiming — by a race for net zero?

What happened?

The lights are back on in the Iberian peninsula, but its residents remain — in the metaphorical sense — in the dark. They still do not know what caused the worst power cut in Europe for 20 years. They are not short of theories though.

President Putin has been blamed, naturally — but the Spanish grid Red Eléctrica has for now ruled out cyberattacks. The impact of space weather, such as charged particles from the sun overloading the system, was mooted. But there was no recorded surge.

Weather on Earth has also been mentioned, with reports — later denied — that “extreme temperature variations in the interior of Spain” caused “anomalous oscillations in the very high voltage lines”.

Tens of millions left without power in Europe after ‘freak weather’

On Tuesday, Pedro Sánchez, the prime minister of Spain, promised an investigation and was particularly emphatic in ruling out another theory — that it was due to “an excess of renewables”.

He would have been aware though that two months ago Red Eléctrica had issued a note to investors. It warned that the proliferation of renewables “increases the risk of operational incidents”. It referenced, in particular, something called “inertia”.

Spanish Prime Minister Pedro Sánchez giving a televised address during a widespread power outage.

Pedro Sánchez, the prime minister, said power would be restored across Spain “soon” but gave no “conclusive information” about the cause of the power cut

FERNANDO CALVO/LA MONCLOA/AFP/GETTY IMAGES

Sánchez would also have been aware that some Spanish engineers were arguing that whatever the proximate cause, a rapid decarbonisation of the country’s grid — and a resulting loss of that inertia, which provides the ability to buffer sudden losses — had risked worse disruption.

“The higher the renewable penetration, the lower the robustness of the grid,” said Miguel de Simón Martín, from the University of Léon, Spain.

How do grids cope with sudden losses?

In modern grids even contingencies have contingencies. At the most basic level, they use the “N-1” system. What this means is that at any given moment, there should be enough slack to cope with the single largest generator going down.

This isn’t simply a matter of having a power plant on standby though. Power stations take time to turn on.

Power cut chaos stops play at Madrid Open

So if, say, the cable to a large solar plant near Seville is tripped, then you would need an instantaneous grid response to boost generation elsewhere in the seconds afterwards. Then you need, perhaps, a battery response to provide a buffer for a few minutes. All this buys time to bring on proper generators.

If the N-1 system was working properly then this week’s blackouts were extraordinary bad luck. To have several systems independently tripping requires either improbable coincidences or perhaps — through a cyberattack — malice.

Is there a reason the system, and in particular the instantaneous response, may have not been working so well?

People boarding commuter buses at a train station after a power outage.

Buses provided rail-replacement services at Atocha station in Madrid after the power cut brought trains to a halt

THOMAS COEX/AFP/GETTY IMAGES

What is inertia?

For almost all the time that humans have made electricity, they have done so by spinning things. In a typical power plant, a big lump of metal turns 50 times a second in a magnetic field, oscillating a current back and forth. This is why our current is described as “50Hz”.

The fact that the wheel turns has an odd bonus. If a 40 tonne wheel spins at 3,000rpm, it takes a lot to stop it. If, in fact, there is a sudden loss of supply, the wheels in the still connected power plants will respond. Very briefly, the grid makes up the difference by drawing on their inertia, and does so automatically.

This is what provides the initial buffer against sudden losses and ensures that everything runs at the 50Hz frequency it is meant to.

Electricity pylon against a cloudy sky.

A pylon in Barcelona after the power cut

ALBERT GEA/REUTERS

The problem — and it is a problem grids have long been aware of and preparing for — is that solar panels and wind turbines do not have big spinning wheels. They don’t automatically respond to fluctuations.

One speculated scenario to explain the Spanish and Portuguese blackout is that a sudden loss of power caused a big shift away from 50Hz that could not be corrected. This in turn tripped protection mechanisms on other renewable plants, that needed to run at 50Hz, leading to a cascade of failures.

Victor Becerra, from Portsmouth University, is one of those who said that inertia could be key in explaining such a collapse. “These are complex, dynamic systems. When they perturb in one place, that propagates through the system,” he said. “When there is strong penetration of renewables you have the challenge there may be insufficient inertia to control the perturbation.”

What can we do about it?

Outside Liverpool there is a big wheel which turns at 3,000rpm. What is unusual about this wheel is that it is not connected to a generator. It simply exists to be on the grid, turning. It is there for inertia. In the UK we have other sources of inertia, such as Drax power station and nuclear power stations. There are plans to increase battery storage in the UK ten-fold, in part to provide millisecond responses to power loss.

Iain Staffell, from Imperial College London, said that this was clearly needed. “If we don’t want to go back to a world of spinning things burning fossil fuels, we need to build more batteries and other storage,” he said.

Eventually, we will find out the reason for this week’s blackout. It may have nothing to do with inertia. However, David Brayshaw, from Reading University, said: “We are used to these large rotating lumps of metal. Not having them is not a reason not to go down the renewable path, it’s a reason to think carefully about what you are doing.”

Becerra added that, if nothing else, this week’s events were a reminder of the sheer complexity of engineering that goes into (most of the time) keeping the lights on.

“These systems are extremely reliable. But they are made by human beings, they are not perfect, and they happen to fail occasionally.”