Injury-hit Real Madrid snatched a 2-1 victory at Real Betis on Sunday, earning their first La Liga win of the year thanks to a late free kick from Dani Ceballos to return to the top four.
Santiago Solari's side, who were missing seven first-team players and lost Karim Benzema to injury at the end of the first half, were pegged back by former forward Sergio Canales who levelled in the 67th minute with a scrappy finish through the legs of stand-in goalkeeper Keylor Navas.
The goal, awarded after a video assistant referee (VAR) consultation, looked set to pour more misery on the misfiring European champions who drew with Villarreal and lost to Real Sociedad in their first two games of 2019.
But substitute Ceballos, a former Betis player, secured a vital win with two minutes remaining, sending his free kick outside the Betis wall and into the corner, prompting boos from his old club's supporters and relieved celebrations from his team mates.
"We really had to suffer for these three points, which feel like gold for us," said Ceballos, who took the ball off usual free kick taker Sergio Ramos to strike the decisive goal.
"I wanted to take it and I was feeling confident, Sergio knew that and I found the hole in the wall and scored."
The victory took Real Madrid above Alaves and into fourth place on 33 points, although they are still 10 points behind leaders Barcelona who beat Eibar 3-0.
Madrid's long absentee list, which included Gareth Bale, Marco Asensio, Thibaut Courtois and Toni Kroos, prompted Solari to field an unorthodox 3-5-2 formation but the Argentine again opted to leave out fan favourite Isco and also dropped the experienced Marcelo.
Madrid lost Benzema, their one fit forward, to a fractured finger and were forced to turn to 21-year-old Cristo Gonzalez, who came off the bench for his La Liga debut.
Betis, who outplayed champions Barcelona and won 3-2 at the Nou Camp this season, monopolised possession after the interval and pinned Madrid back around their area.
There was an air of inevitability about Canales' equaliser and Betis hunted a winner, but Real showed grit to withstand the pressure before Ceballos struck.
"We're very sad to not even have got a draw, we deserved to get a better result," said Betis coach Quique Setien.
"In the first half we made some mistakes but we were much better in the second and created a lot more danger. But you can never write off Real Madrid."