Arturo Vidal headed Bayern into a first-half lead, but then skied a penalty attempt on the stroke of half-time 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 kick-off when the announcer made reference to Dortmund's ordeal in the preceeding 24 hours.
Bayern suffered a blow before kick-off when top-scorer Robert Lewandowski, who has netted 38 goals this season, dropped out with a bruised shoulder and Thomas Muller deputised as striker.