The loss made their dream of qualifying for the final of the Champions League likely a mission impossible.
No thanks to Lionel Messi, who struck a late brace and Neymar, who netted in added time to leave the Germans in a difficult place.
The match had been an absorbing contest between two high-class sides.
But matters took a twist in the 77th minute.
The men from Munich looked solid as a rock for a long spell after half-time, but a moment of defensive carelessness let in Messi to open the scoring on 77 minutes, the Argentine doubling his tally with a deft finish three minutes later and Neymar scoring in the last minute of stoppage time to hand the Catalans a daunting advantage.
Camp Nou was packed with 95,635 people who watched the match.
Bayern now have a daunting task to upturn Barcelona advantage at the Allianz Arena next Tuesday.