Kevin De Bruyne scored and assisted in the same Champions League game for only the second time in 59 appearances in the competition, after doing so against Real Madrid in February 2020
City delivered a magnificent display as they peppered Real's goal for long periods but Carlo Ancelotti's side kept rising off the canvas to somehow keep themselves in serious contention to reach another final.
Kevin de Bruyne set the tone for a magical night of football with a diving header from Riyad Mahrez's cross in the second minute and in-form Gabriel Jesus quickly added a second from close range as Real reeled under wave after wave of attacks.
Mahrez enraged manager Pep Guardiola when he hit the side-netting instead of finding the unmarked Phil Foden, who shot inches wide before Karim Benzema, inevitably, gave Real a lifeline by sweeping home Ferland Mendy's cross after 33 minutes.
The Spanish side escaped again shortly after the break when Mahrez struck the post but City restored their two-goal advantage when an unmarked Foden headed home Fernandinho's cross in the 53rd minute.
City were pegged back again when Vinicius Junior dummied past Fernandinho and ran from inside his own half to score a superb second for Real.
However, a brilliant use of advantage from referee Istvan Kovacs allowed Bernardo Silva to fire into the top-left corner for City's fourth.
There was still no let-up and Benzema capped a spectacular game by showing nerves of steel to chip a Panenka penalty past Ederson with eight minutes left following Aymeric Laporte's handball.
Liverpool face Spanish side Villarreal in this year's other semi-final, with the first leg at Anfield on Wednesday.
The final will be held at the Stade de France in Paris on Saturday, 28 May.
City would have taken any sort of advantage to Spain before kick-off but deep down they will know their almost total dominance of Real should have given them much more than this narrow lead for the second leg.
Guardiola's side were simply irresistible for spells and could have been four goals ahead before Benzema struck Real's first, the manager clearly infuriated by Mahrez's selfishness in shooting with Foden standing unmarked in front of goal at 2-0.
Guardiola and his players will take heart from the manner in which they carved Real open so often and they will hope to capitalise on their opponents' need to press for a goal in Spain.
Bernardo Silva and Phil Foden both scored for Manchester City in the second half
De Bruyne was outstanding once more and Foden just showed how at home he is on the elite stage, but City have to be concerned at how they looked defensively vulnerable on occasion to leave Real very much alive in this semi-final.
A side of City's calibre will be confident of progress - but most observers will know this tie should already be over.
Real will always have hope when they have Benzema, the 34-year-old Frenchman who deserves his place in the upper echelons of the great strikers in world football.
It is often a mystery how Real survive when looking punch drunk having come back from losing situations to beat Paris St-Germain and Chelsea in their previous knockout ties.
But a comeback looked beyond them when they were blown away by a blistering City opening that left them two down after only 11 minutes.
And yet, for all their struggles elsewhere, the La Liga leaders carry an air of menace that means concentration levels cannot drop for a moment. They proved it again as they dusted themselves down to give themselves a lifeline.
It was no surprise that Benzema was the man responsible, showing all of his class with a left-foot volley past Ederson to make it 2-1.
Brazilian youngster Vinicius Junior also produced magic for the second goal before Benzema's nerveless penalty.
The great survivors are still in this tie and will now hope the magic of the Bernabeu can inspire them once more next week under coach Carlo Ancelotti, who is trying to win the trophy for a fourth time.
-- Courtesy of BBC Sport