Real Madrid shocked Deportivo La Coruna to win 3-2 in stoppage time at the Santiago Bernabeu and make history as their unbeaten run extended to 35 matches.
Manager Zinedine Zidane made eight changes and looked to be set to pay the cost when a quickfire double from former Real Madrid Castilla forward Joselu in the space of two second-half minutes turned the match around after a fine opener from Alvaro Morata.
However, substitute Diaz Mariano equalised with six minutes left and Sergio Ramos sent the Bernabeu into delirium when he powered in a header from a corner during stoppage-time.
The victory moved Los Blancos back to six points ahead of Barcelona, who had won 3-0 at bottom club Osasuna earlier in the day, and eclipsed the club landmark set by Leo Beenhakker's side from the 1988/89 season.
"It was a crazy game, but I'm happy," Zidane said after the match.
"We suffered a lot today.
"Yet the players gave everything right to the very end."
According to the coach, every Real Madrid player on the pitch contributed to the victory, with Lucas Vazquez, Mariano and Marcelo also making a difference when they came off of the bench.
"The substitutions played their part and it was a good game from everyone," Zidane told reporters.
"I truly want to thank the players.
"I also want to thank the fans, who helped us tonight."