
He announced the decision at the end of a long session in Congress on Tuesday evening.
Puente had given evidence about last Wednesday's disaster and outlined new rail safety measures before facing tough questions from the opposition.
The crash happened near Urda, south of Madrid, when a train ran into the back of a stationary one.
Puente said a transport minister in a country like Spain cannot stay in office after two accidents this serious in less than a year.
He was referring to a January crash on the same line that killed 46 people.
The latest disaster is one of the worst rail accidents in Europe's modern history and Spain's deadliest since 2013.
Puente also said he is withdrawing from the lists for the early general elections.
Those elections are set for November 29.
His position had been under pressure since the crash.
The conservative People's Party and the far-right Vox both called for him to step down, and some of the government's own allies agreed.
Critics said the system had failed and accused Puente of blaming human error to shift responsibility.
Prime Minister Pedro Sánchez himself admitted the rail system's credibility was "broken."
Just days earlier, Puente had said he would stay in his post, so his sudden exit caught many people off guard.
Observers see the crash as a serious blow to the Socialist-led government ahead of the election.
.jpg)
(Rescuers had to use heavy lifting equipment. Photo by BBC News)
Sánchez praised Puente for taking responsibility and stepping aside.
Puente said he resigned out of "political dignity."
The crash involved a Renfe train carrying 397 passengers and a stationary Iryo train carrying 147.
An automatic signalling fault had halted trains on the stretch.
Leaked audio from Madrid's control centre, published by Spanish media shortly after the crash, appears to show that the Renfe driver was told to continue at normal speed under a backup signalling system, even though the Iryo train had stopped about 25 km ahead.
Iryo said its carriages were struck from behind.