Puente announced his decision at the end of a congressional session on Tuesday evening in which he had outlined new rail safety measures and been grilled by the opposition.

He said he had taken the decision immediately after the 28 October disaster.

Puente had been under mounting pressure as opposition parties and some allies of the government called on him to step down.

Leaked audio recordings published in Spanish media soon after the crash revealed conversations between train drivers and a control centre just minutes before the disaster.

Three tapes between Madrid’s control centre and two train drivers appear to show that one high-speed train was given clearance to move even though another train had stopped on the track, about 25km (15 miles) ahead.

Prime Minister Pedro Sánchez has said that authorities will “get to the bottom of every last detail of this tragedy”.