Substitute Dani Ceballos scored from a free kick in the final minutes to save Real Madrid from another setback in the Spanish league title race on Sunday.
Ceballos sent his strike through a gap in the defensive wall to claim the winning goal in a 2-1 victory at Real Betis.
Ceballos, who joined Madrid from Betis before the start of last season, went on in the 74th minute to jeers from Betis fans and with Madrid on the defensive.
But when Casemiro earned a foul just outside the box, Ceballos stepped up to score the goal that will take some pressure off beleaguered Madrid coach Santiago Solari.
Digital Access for only $0.99
For the most comprehensive local coverage, subscribe today.
"I had a lot of confidence and was eager to show what I can do," Ceballos said. "These three points are golden."
Madrid, which hadn't won in its two previous league games, moved past Alaves into fourth place, level on points with third-placed Sevilla, with both teams 10 points behind leader Barcelona.
Ballon d'Or winner Luka Modric put Madrid in front in the 13th with a shot from the top of the area.
But Madrid's injury problems were compounded when Karim Benzema left the match at halftime after appearing to hurt his right hand.
Betis got the equalizer in the 67th when former Madrid midfielder Sergio Canales received a throughball from Giovani Lo Celso, fended off Nacho Fernandez and poked the ball under goalkeeper Keylor Navas.
Madrid was already without Gareth Bale, Toni Kroos, Marco Asensio, Mariano Diaz and goalkeeper Thibaut Courtois due to injury, while Lucas Vazquez was suspended.
Solari, however, still left Spain midfielder Francisco "Isco" Alarcon on his bench, even after Benzema went down. Instead he replaced Benzema with Cristo Gonzalez, a player from Madrid's reserve team.
Solari, who coached Madrid's reserve team until he was promoted to replace Julen Lopetegui in October, said that he didn't have anything "personal" against Isco, or Marcelo, whom he also left on the bench.
"Everyone can play, we are all part of a group. I have said so from day one," Solari said. "We can incorporate players from the reserve squad, just like is happening. Each player is important."