After a frenetic but ultimately goalless first half at the Allianz Arena, Bayern scored twice in four minutes after the break through Lucas Hernandez and Leroy Sane. The victory moves the German champions top of Group C, three points above second-placed Barca.
Barcelona had more possession than Bayern and outshot the hosts 18-13.
"I am angry. I do not like to lose. We have not deserved it," said Xavi, who oversaw a defeat to Bayern last season in his sixth game in charge that sent the Catalans crashing out in the group stage.
"Last year I was angry because they were far superior to us. Today I think we played better than Bayern. We dominated them, we subdued them.
"We created many clear chances to score and it would have changed the match. In Champions League matches, it's always about details.
"At this level everything is very even and you pay for these mistakes and today it is a hard learning, but it is like that."
Xavi said his team need to minimise their mistakes if they are to be successful.
"There was an error at a corner, there was an error in a transition that we did not stop and they have stopped transitions many times," he said.
"And then what we have failed, we have failed a lot, there has been a lack of effectiveness that we have normally had ... So the way to play was very good, positive for this part, but negative for the result."
It was a forgettable return to Munich for Robert Lewandowski, who left the Bavarians for Barcelona this summer. The Polish striker has enjoyed a prolific start to life in Spain with nine goals in his first six games but was unable to add to that tally in his seventh appearance, despite several good chances.
Xavi insisted that the entire team needs to be more ruthless in front of goal after a match where Bayern's clinical finishing proved the difference.
“The difference between us and Bayern is that they don’t forgive in front of goal,” he said. “The result is not a reflection of the entire match. But this is the Champions League. If you miss chances, you will end up paying that. We messed up. This defeat is a step backwards."
Barcelona return to La Liga action on Saturday with a home match against Elche. Bayern, who ended a run of three straight draws by beating Barca, travel to Augsburg in the Bundesliga also on Saturday.