The Portugal captain struck two minutes after the break to cancel out Arturo Vidal's bullet header before poking home a second to give the holders a strong result to take back to the Santiago Bernabeu for the return fixture.
Bayern had been good value for their lead but Vidal's missed penalty allowed Madrid to get back into the match, before a red card for Javi Martinez left the Bundesliga leaders facing a battle to ensure they stayed in the tie.
The first half belonged to the home side and Vidal in particular, the midfielder scoring with one emphatic header, missing a clear chance for a second and blazing a controversial spot-kick over the crossbar.
Madrid responded through Ronaldo's first goal in the tournament since September 27 and Martinez's two quick-fire yellow cards gave them a foothold they never looked likely to relinquish, before Ronaldo's second 13 minutes from time sealed the win - his 100th goal in European competition.
The tie is far from over for Carlo Ancelotti's side but the advantage rests with Zinedine Zidane, the man who won the competition as assistant to Ancelotti in 2014 before his triumph at the Madrid helm last year.
Madrid came closest to breaking the deadlock in a balanced opening 20 minutes, Karim Benzema seeing a downward header clawed onto the underside of the crossbar and out by Manuel Neuer, back in the side after missing the last three matches with injury.
Bayern, though without the injured Robert Lewandowski, turned up the attacking pressure and a succession of corners eventually paid dividends. Vidal raced through the crowded box to meet Thiago Alcantara's delivery and the Chile international powered a header high into the net, despite Keylor Navas getting hands to the ball.
The home side sought to cement their control and Vidal spurned a great chance to make it 2-0, heading high and wide from 12 yards out after Arjen Robben got free of Toni Kroos by charging for the byline rather than cutting inside from the left.
Vidal was then given the chance to cap a superb first half from the penalty spot but he blazed his effort over the crossbar, although Madrid will certainly feel that justice had been done after the assistant behind the goal had incorrectly ruled that Dani Carvajal had blocked a Franck Ribery effort with his arm.
Zidane had to jog to reach the dugout in time for the second half after delivering a lengthy team talk, and he did not have to wait long to watch his side restore parity. Luka Modric found Carvajal in space down the right, and his cross was expertly swept into the bottom-left corner by Ronaldo, who was allowed to meet the ball unchallenged near the penalty spot.
Bayern appeared not to learn their lesson and Neuer was forced into a superb one-handed save to keep out a header from Gareth Bale, who was allowed to latch onto Modric's driven cross from much the same position that Ronaldo had scored.
With the away goal secured, Madrid looked content to hit Bayern on the counter-attack, and the tactical tweak brought them a further advantage as Martinez picked up two yellow cards in the space of three minutes for fouling Ronaldo as he looked to break into the hosts' half.
Neuer was again required to keep the scores level, sticking out a leg to deny Benzema's prodded effort after Carvajal had fed the striker, before a strong right arm stopped a firm Ronaldo strike from 12 yards.
But Ronaldo got the better of Germany's number one for the second time in the 77th minute, racing to meet Marco Asensio's curling cross from the left and prodding the ball through Neuer's legs and into the net.
Madrid thought they had snatched a potentially vital third goal when Sergio Ramos steered in a header in the 90th minute, but the assistant referee spared Bayern after correctly spotting that the visiting captain was offside.
Key Opta stats:
- Cristiano Ronaldo has scored six times in five previous Champions League games against Bayern Munich.
- Arturo Vidal has scored three times in his last two Champions League games, as many as he had in his previous 29 appearances in the competition.
- There were 173 seconds between Javi Martinez’s first and second yellow cards in this match.
- Only Juventus (22) have received more red cards in Champions League history than Bayern (18, level with Arsenal).