Barcelona slumped to a shock 2-1 defeat at lowly Deportivo La Coruna on Sunday and lost top spot in La Liga to Real Madrid, who recovered to beat Real Betis 2-1 thanks to a header by the irrespressible Sergio Ramos.
Real fought back after a calamitous own goal from keeper Keylor Navas gave Betis the lead in the 25th minute, just after the Costa Rican escaped a possible red card. Cristiano Ronaldo pulled the hosts level in the 41st with a diving header.
Betis had defender Cristiano Piccini sent off for a second booking in the 78th and three minutes later Ramos nodded in his 10th goal in all competitions this season, adding to his header in the 3-1 win at Napoli in the Champions League on Tuesday.
Real lead the standings on 62 points, Barca are second with 60, and Sevilla are third on 57 after a 1-1 draw at home to Leganes on Saturday. Real have a game in hand on their rivals.
Betis were incensed when referee Antonio Mateu Lahoz waved play on after winger Darko Brasanac slipped through Real's high defensive line to hurtle towards goal and was knocked over by the advancing Navas, who could have been sent off.
The goalkeeper seemed fazed by the incident, however, and a couple of minutes later allowed a tame shot from Antonio Sanabria through his hands and knocked the ball over the line with his glove, covering his face to hide the embarrassment.
Betis were denied a penalty later in the half when Sanabria was knocked over by Dani Carvajal and a few minutes later Ronaldo pounced on poor defending from the visitors to equalise.
Ramos completed the turnaround by leaping to head in a Toni Kroos corner and Navas made amends for his earlier blunder by keeping out a close range header from Sanabria.
"This is a very complicated stadium where the demands are infinite and when players make mistakes they need support. Keylor saved us at the end and I'm happy he has recovered from their goal," Ramos told reporters.
"It was a strange game, we did some things well but Betis defended well and they scored with the few chances they had which put us up against it, but it was vital to win today to go top."
Elsewhere, Villarreal moved above Real Sociedad into fifth on goal difference with a 1-0 win at Celta Vigo, capitalising on Sociedad's 2-0 home loss to Athletic Bilbao in a Basque derby.