Real Madrid staged a late rally to beat Girona 4-2 in their Copa del Rey quarter-final first leg on Thursday thanks to goals from Sergio Ramos and Karim Benzema in the space of three minutes.
Winless in nine matches in all competitions, Girona took the lead with a seventh-minute goal from Anthony Lozano, but Real regained control after Lucas Vazquez equalised from inside the area 11 minutes later.
Ramos then converted a Panenka-style penalty three minutes before the break after Vinicius Junior was fouled inside the area.
In the second half, Girona came back with a penalty of their own, converted by captain Alex Granell in the 66th minute after a handball by Real Madrid midfielder Marcos Llorente, who had come on only a few minutes earlier.
Ramos came to the rescue again not long after, scoring with a header into the top corner after a cross by Marcelo for his 102nd career goal. Benzema increased the lead in the 80th minute with a touch from close range after a low cross by Vinicius Junior.
The victory increases Santiago Solari's side's chances of reaching the last four in the Copa del Rey for the first time since they won the competition in 2014.
Elsewhere on Thursday, Real Betis scored late to draw 1-1 in their quarter-final first leg with Espanyol in Barcelona.
It was an open match from the start at RCDE Stadium, with both goalkeepers having to make several difficult saves, and Borja Iglesias put the hosts ahead from close range in the 27th minute.
Betis had a goal disallowed for offside in the 63rd minute before Antonio Sanabria levelled things up following a quick counter-attack with nine minutes to play.