Jude Bellingham inspired Real Madrid as they came from two goals down to beat La Liga bottom side Almeria in a breathless encounter.
The winless visitors took a shock 2-0 lead at the Bernabeu with goals from Largie Ramazani and Edgar Gonzalez.
England midfielder Bellingham scored a 57th-minute penalty before Vinicius Jr equalised 10 minutes later.
In the ninth minute of added time, Bellingham headed across for Dani Carvajal to poke in the winner.
The dramatic late victory helped Real leapfrog Girona and move two points clear at the top of La Liga.
Girona, though, could return to the summit later this evening if they beat Sevilla at home.
Real were expected to brush aside an Almeria side who have picked up just a solitary point on the road in a miserable 2023-24 campaign.
But on the back of a goalless draw at home to Girona last time out, the Andalusian outfit stunned the hosts with a goal after 38 seconds.
Neat build-up play after they pinched possession allowed Lucas Robertone to slip in the unmarked Ramazani and his low effort wrong-footed Kepa Arrizabalaga.
Gonzalez’s sweetly struck half-volley in the 43rd minute then flew over a flat-footed Kepa to increase Almeria’s advantage.
But Real were awarded a debatable penalty after the Video Assistant Referee (VAR) decided the ball had brushed the arm of Kaiky, with Antonio Rudiger deemed not to have committed a foul in the build-up.
Bellingham stepped up to net his first La Liga spot-kick as he confidently sent Almeria goalkeeper Luis Maximiano the wrong way.
Almeria thought they had a third when Sergio Arribas slotted the ball past Kepa from Ramazani’s cross but the VAR overruled it.
Vinicius Jr then levelled with another controversial goal, which was initially ruled out for handball after the Brazilian appeared to guide it in with his arm.
However, the referee reviewed it on the pitchside monitor and overturned his original decision.
Almeria boss Gaizka Garitano was sent off for a second booking for dissent as Real snatched a winner in the ninth of 11 minutes of injury time.
A deep cross from a Real counter-attack picked out Bellingham who directed his header to the opposite side of the six-yard box where Carvajal applied a close-range finish.