Zinedine Zidane's team, without the rested Cristiano Ronaldo and injured Gareth Bale, had already equaled Barcelona's Spanish record of 39 games undefeated, but looked to be falling just short of eclipsing its great rival.
Trailing 3-1 to Sevilla going into the final seven minutes of the Copa del Rey round of 16 second leg, Sergio Ramos' impudent Panenka
penalty halved the deficit and gave his side hope.
The Real captain, a former Sevilla player and a product of its youth system, celebrated against a backdrop of boos and middle fingers.
It wasn't until the final minute of injury time, however, that Real got the equalizer.
Marcelo's deft back-heel found Karim Benzema outside the penalty area, before the Frenchman surged into the box and slotted the ball into the bottom corner -- via a fortuitous deflection.
Cue rapturous scenes on the Real bench, as the club set a new Spanish record of 40 games unbeaten and qualified for the quarterfinal in the process.
"It was a tough game, very draining," Zidane said after the match. "They (Sevilla) played incredibly well and deserved more from the game in truth.
"After that first goal we eased off a bit and they were able to put two past us. In the end we were able to get a draw. Over the course of the two games we deserved to go through.
"We really had to soldier on against a resilient side who are fast-paced and home support who really pile the pressure on."
Real last tasted defeat against Wolfsburg in the Champions League quarterfinal first leg in April.
In Zidane's 56 games as coach, the Frenchman has won more titles than he has lost matches -- clinching the Champions League, Club World Cup and UEFA Super Cup, while suffering just two defeats.
The two sides meet again in La Liga Sunday with Sevilla, rejuvenated this season under the guidance of Argentine coach Jorge Sampaoli, still in the title race and just four points behind leader Real.
Zidane's side will then go on to play Celta Viga in the Copa del Rey quarterfinal first leg next Wednesday.