Missed chances by Robert Lewandowski on his return to Bayern Munich proved costly as his Barcelona side lost in Germany.
Outplayed in the first half, Bayern blew their Spanish opponents away after the break with goals from Lucas Hernandez and Leroy Sane.
Hernandez headed in at the near post after 50 minutes, before Sane clipped home to seal the win shortly after.
Lewandowski spurned a number of clear openings in an entertaining match.
The victory puts Bayern Munich in control of Group C with six points from two games.
Barcelona are level on three points with Inter Milan, who beat Viktoria Plzen 2-0 in the Czech Republic through goals from Edin Dzeko and Denzel Dumfries.
Unhappy return for Lewandowski
This absorbing encounter between two European heavyweights more used to meeting in Champions League knockout games rather than the group stage was Lewandowski’s first return to Bayern since his move to Xavi’s Barcelona last summer.
Despite a protracted transfer saga after the 34-year-old openly stated his desire to leave the Bundesliga champions, the Munich fans seemed to bear little ill will, giving the Pole a good reception before the game.
Lewandowski had scored nine goals in six games for his new club before Tuesday night, but he missed several good first-half chances at the Allianz Arena.
The best came on 18 minutes, with a great ball with the outside of the boot from Gavi setting him up with a volley from eight yards which he put over the crossbar when he should have hit the target.
He was also denied by Manuel Neuer with a far-post header, the veteran Bayern keeper responsible for his side reaching half-time goalless having earlier saved well with his legs from midfielder Gavi.
Barca were then severely punished for their star striker’s profligacy with their best second-half chance falling to Gavi, who hit the post.
Robert Lewandowski (right) scored 46 goals in 42 games under Julian Nagelsmann
Nagelsmann eases the pressure
Any failure to win a game leads to an inquest at Bayern – three successive draws in the Bundesliga has meant a mini-crisis and questions over manager Julian Nagelsmann’s job.
The 35-year-old made made five changes including dropping big-money summer signing Matthijs de Ligt to the bench following his foul to give away a late penalty in Saturday’s 2-2 draw with Stuttgart. He was replaced by French World Cup winner Hernandez, who made the first game-changing contribution.
Nagelsmann’s changes did not have the desired impact immediately, with Bayern regularly picked apart in a frenetic, end-to-end first half, struggling to find the final ball when they had possession in Barca territory.
The Bayern manager introduced Leon Goretzka at half-time to try and establish control over the midfield and, while it was an old-fashioned set piece which provided the break through on 50 minutes, the second shortly after came through a superb move mixing teamwork and individual skill.
First, an inswinging near-post corner from Joshua Kimmich was met by the head of Hernandez, escaping the marking of Marcos Alonso and beating goalkeeper Marc-Andre ter Stegen to the ball.
Four minutes later, patient build-up play from the back set up a driving run from midfield by Jamal Musiala. He then played in Sane who left Jules Kounde for dust before a cute chipped finish over Ter Stegen for a superb second.
It was not all positive for Nagelsmann however – Sane reacted badly to being replaced with 10 minutes to go, throwing down his water bottle and storming from the bench.
The artificial turf covered doors to the subterranean bench had to be opened for Sane to make his angry exit. The trap doors and pitfalls too remain a danger for Nagelsmann, despite this pressure-easing victory.