The Catalan outfit entered the match needing only a point to book their spot in the knockout round of the European competition with two games to spare.
However, Danylo Sikan's first-half effort proved to be the difference between the two sides in Hamburg, with Shakhtar securing all three points.
Barcelona remain top of Group H, but they are now level on points with second-placed Porto, while Shakhtar are only three points behind in third position.
Xavi has branded the contest "one of the worst games" since his arrival as head coach towards the end of 2021.
"The Champions League requires the highest level and today we were not like that. We will leave angry. We did not play a good match. In the second half we tried very bravely, but it did not go as planned," Xavi told reporters.
"It's a shame because we wanted to qualify for the next round today. It's a step backwards. The knockout stage in danger? I'm not worried about the match against Porto because we still rely on ourselves to qualify.
"At the moment the main thing is to recover for the Alaves match. Today we couldn't fail and we failed. It's a big mistake.
"We played one of the worst games since I arrived two years ago. We are not there mentally. We are doing things wrong in general, we have problems offensively and defensively.
"We have to get the players back so they feel comfortable on the pitch. An important step must be taken."
Meanwhile, Barcelona goalkeeper Marc-Andre ter Stegen told reporters: "We are angry with ourselves because the result cannot happen to us.
"They created a chance for us in the first half and we couldn't find the formula. We are left with the feeling of having lost a game that we had to win and to get into the next phase of the Champions League."
Barcelona have now lost two of their last three matches in all competitions, having also suffered a 2-1 defeat to Real Madrid in El Clasico at the end of last month.
The Catalan outfit will be bidding to bounce back from the loss in Germany when they resume their La Liga campaign at home to Alaves on Sunday afternoon.