Bayern were on the front foot from the off and took the lead when Joshua Kimmich's corner was flicked into his own net by Erick Pulgar in only the sixth minute.
Just moments later it was 2-0. The ball fell for Harry Kane after Dayot Upamecano did well to win possession and the England captain fired in a fierce left-footed strike from distance to double his side's advantage.
Flamengo had fallen behind early on during their comeback win over Chelsea and did show some spirit again as Luiz Araujo forced Manuel Neuer into a smart save. Their efforts were rewarded just past the half-hour mark when Gerson arrived on the end of a cross and lashed a shot into the roof of the net. However, the two-goal deficit was restored shortly before half-time.
A bad Araujo clearance fell to Leon Goretzka and the Germany international hit the target from long range, completely wrong-footing goalkeeper Agustin Rossi to make it 3-1.
Bayern had earned their dominant position but a lapse in concentration cost them as Michael Olise was penalised for handball, having raised his hands at a corner. A penalty was given and former Arsenal midfielder Jorginho converted in his own unique style to cut the lead down again.
The threat of Flamengo drawing level hanged around throughout the second half but again Kane was on hand to keep his side firmly on top, finishing clinically from the edge of the box for his second of the match.
The Bundesliga giants ended up seeing the game out, booking a quarter-final date with PSG next weekend.