Arturo Vidal headed Bayern into a first-half lead, but then skied a penalty attempt on the stroke of halftime before Ronaldo volleyed the defending champions’ level.
Bayern played the last half an hour a man down after centre-back Javi Martinez was sent off for two fouls on Ronaldo within three minutes of each other.
Four-time world player of the year Ronaldo then slotted in the winner between goalkeeper Manuel Neuer’s legs for the winner 13 minutes from time.
Security was tight at the Allianz Arena in the wake of Tuesday’s attacks on the Borussia Dortmund team bus, and both teams arrived with a heavy police escort.
There was a large police presence and inside the stadium, there was polite applause before kickoff when the announcer made reference to
Bayern suffered a blow before kickoff when top-scorer Robert Lewandowski, who has netted 38 goals this season, dropped out with a bruised shoulder, and Thomas Muller deputised as striker.
Bayern were also missing injured
Bayern went ahead on 25 minutes when playmaker Thiago Alcantara swung in a corner from the right which Vidal powered through Real goalkeeper Keylor Navas’s hands.
Real made a poor start, rarely threatening
A strong drive from Ronaldo on 41 minutes which Neuer blocked, having palmed a Benzema header on to the woodwork with 18 minutes played, were their best first-half chances.
Vidal could have finished with a first-half hat-trick when he stepped up to take a penalty after Dani Carvajal’s handball from a Franck Ribery shot.
However, the Chilean smashed the spot-kick high over the crossbar.
It was a miss Bayern were soon to regret.
Real were level two minutes after the break when Carvajal found space on the right and fired in a cross, which Ronaldo volleyed past Neuer.
Bale, who has laboured with an ankle injury recently, came off on 58 minutes and Real raised the tempo after he trudged off.
Having already picked up a yellow card for pulling Ronaldo back on 58 minutes,
Real’s superstar then hit the winner as substitute Marco Asensio, on for Bale, put in a low pass for Ronaldo to tap the ball home between Neuer’s legs.
Real defender Sergio Ramos had the ball in the Bayern net with time running out, but the goal was ruled offside.
But the Spaniards have the upper hand for the second leg at home next Tuesday.