Cristiano Ronaldo's last-minute winner gave Real Madrid a thrilling victory over Manchester City in a pulsating Champions League clash at the Bernabeu.
City keeper Joe Hart kept his side in the game before they took a shock lead through Edin Dzeko's breakaway goal.
Marcelo equalised with a deflected shot but City led again when Aleksandar Kolarov's free-kick flew straight in.
In a frantic finale, Karim Benzema levelled before Ronaldo's shot flew past an unsighted Hart to win it.
That brought a spectacular sliding celebration from Real boss Jose Mourinho - who had questioned his side's focus and commitment in recent days - and provided an extraordinary finish to a game which had been completely one-sided for long periods.
The Spanish side dominated until Dzeko put City ahead after the hour mark, with Hart rescuing his side on several occasions.
Real's Bernabeu record
If Manchester City had held on to win at the Bernabeu, it would have been the first time in Real Madrid's history that the nine-times European Cup champions had fallen to defeat in their first home match of the competition, a record now consisting of 41 wins and two draws, the most recent of which came against Anderlecht, exactly 50 years ago.
But, having led with less than three minutes remaining, Roberto Mancini's men will still feel they should have won the game, let alone finish up empty-handed as they began their campaign in Group D.
A trip to the home of the Spanish champions always looked a tough way for City to begin their task of reaching the knockout stages for the first time, especially because there was no sign of any lethargy or discontent in the Real camp.
They took the game to City from the start and, inside the first five minutes, Ronaldo tested Hart for the first time when he cut inside Vincent Kompany and fired in a low shot that was heading for the bottom corner until the England keeper clawed it to safety.
That set the pattern for the rest of the first half, with Ronaldo giving Maicon a torrid time down City's right, while Angel di Maria and Alvaro Arbeloa saw plenty of the ball on the opposite flank.
Hart had to come to City's rescue again with an instinctive block to keep out Gonzalo Higuain's header from Ronaldo's cross-shot, before racing off his line to close down Higuain after he beat the offside trap.
By now, Real were completely dominant and City were also grateful for some poor finishing from Higuain and Sami Khedira, who both missed the target from point-blank range.
Tellingly, Yaya Toure was City's only attacking outlet before the break, twice causing the Real defence problems after running at them from deep positions but failing to find a decisive final ball.
He was to put that right in style when he again charged forward and fed Dzeko, who steadied himself before firing home.
The goal came completely against the run of play, but it was almost followed by a second for the visitors when Carlos Tevez slipped Toure free. However he was off balance when he let fly inside the box and could only fire into the side netting.
Mourinho made a flurry of changes in a bid to rescue the game, with Benzema and Luka Modric both flung on, and in the end the home side's pressure told.
Marcelo, who had earlier gone close with two fizzing efforts from the edge of the box, made it third time lucky when he stepped inside Vincent Kompany and saw his shot come off Javi Garcia and fly into the net.
The visitors remained on the back foot but they also remained a threat at the other end, and Kolarov restored their lead when he bent the ball straight into the net from 25 yards out.
Again, the travelling fans scented what would have been a famous triumph but, once more, Real came forward, with Benzema turning inside Matija Nastasic before finding the bottom corner to make it 2-2.
From being on the brink of victory, City were now clinging on for a point. There was yet more drama to come, however, and it was former Manchester United star Ronaldo who would provide it.
With the 90 minutes almost up, he cut inside from the left and, after Kompany ducked under his shot, the ball cruelly fizzed past the helpless Hart.
- 01 Casillas
- 02 Varane
- 03 Pepe
- 12 Marcelo
- 17 Arbeloa
- 06 Khedira (Modric - 73' )
- 07 Ronaldo
- 14 Alonso
- 15 Essien (Ozil - 65' )
- 22 Di Maria
- 20 Higuain (Benzema - 73' )
- 13 Adan
- 04 Ramos
- 05 Coentrao
- 08 Kaka
- 10 Ozil
- 19 Modric
- 09 Benzema
- 01 Hart
- 03 Maicon (Zabaleta - 74' )
- 04 Kompany Booked
- 22 Clichy
- 33 Mattija Nastasic
- 08 Nasri (Kolarov - 36' )
- 14 Garcia Booked
- 18 Barry
- 21 Silva (Dzeko - 63' Booked )
- 42 Y Toure
- 32 Tevez
- 30 Pantilimon
- 05 Zabaleta
- 06 Lescott
- 13 Kolarov
- 17 Rodwell
- 10 Dzeko
- 16 Aguero