Francisco “Isco” Alarcón put Madrid ahead in the 60th minute after a mistake by Man City midfielder Rodri, but Gabriel Jesus evened the match with a header in the 78th and Kevin De Bruyne scored the winner by converting an 83rd-minute penalty after a foul by Dani Carvajal on substitute Raheem Sterling.
Madrid played the final minutes without defender Sergio Ramos after he was shown a red card for a foul to stop an 86th-minute breakaway by Jesus.
The return match in England will be on March 17.
In Wednesday’s other game, Lyon beat Italian champion Juventus 1-0 at home.
Pep Guardiola’s team was the most dangerous team throughout the match but couldn’t get past Madrid goalkeeper Thibaut Courtois until Jesus’ close-range header. The Brazilian forward, a surprise starter over Sterling and Sergio Aguero, jumped behind Ramos to meet a well-placed cross by De Bruyne.
Sterling, back in action after nursing a muscle injury, made a crucial impact after coming off the bench by setting up the penalty that De Bruyne calmly converted past Courtois.
Madrid struggled to get clear chances but took the lead after Rodri gave the ball away near midfield. The blunder allowed Vinícius Júnior to make a run into the area and find Isco free from markers for an easy goal.
Madrid historically has thrived at the Bernabéu in the Champions League, but it has won only three of its last 10 European matches at the stadium, drawing three and losing other four. It was eliminated by Ajax in last year’s round of 16 after a 4-1 home loss. That marked the first time since 2009-10 the Spanish powerhouse failed to reach at least the semifinals.
It was the third straight setback for Madrid, which was coming off a draw and a loss in the Spanish league, results that dropped the team behind Barcelona at the top of the Spanish league.
Man City is likely playing in its last Champions League before having to serve a two-year ban from European competitions for breaching financial regulations and failing to cooperate with investigators. The club filed an appeal at the Court of Arbitration for Sport, but if the UEFA punishment stands, City won’t be back in the Champions League until the 2022-23 season.