Real Madrid edged past Real Betis to climb into the La Liga top four with a first win in three matches.
Betis looked set to earn a deserved point until Dani Ceballos’ late free-kick nestled into the bottom corner.
Real were given an early lead by Luka Modric, but the home side dominated possession and equalised through Segio Canales after an offside decision was overturned by VAR.
Madrid climb to fourth, but remain 10 points behind leaders Barcelona.
Earlier on Sunday, Lionel Messi became the first player to score 400 La Liga goals as Barca recorded their seventh successive win to maintain their five-point lead at the top of the table.
Real, European champions in the past three seasons, are nowhere in the title race. They are behind third-placed Sevilla on goal difference and a point ahead of Alaves in fifth.
Though they saw much less of the ball, the visitors had the better of the early chances and Modric’s clinical finish gave them a lead they merited.
Federico Valverde could have made it two, but he hesitated when through on goal, allowing Antonio Barragan to make a sliding tackle.
Betis applied pressure of their own before half-time and again after the break – Andres Guardado volleyed past the post from the edge of the 18-yard box.
When Canales got between the Madrid centre-backs and slid in a finish, the goal looked set to be ruled out for offside, only for VAR to overturn the onfield decision.
Madrid introduced Brahim Diaz, the 19-year-old signed from Manchester City, for his La Liga debut, but were struggling to silence the raucous crowd in Seville.
That was until the intervention of former Betis man Ceballos, himself a substitute. His free-kick penetrated a flimsy wall and went past unsighted home keeper Pau Lopez to give Madrid their first league win since their triumph at the Club World Cup in December.