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.