Barcelona suffered their first defeat under Xavi Hernandez on Saturday as a 1-0 loss at home to Real Betis inflicted another blow on their hopes of catching La Liga's top four.
A surprise defeat at Camp Nou damages Barca's bid to qualify for next season's Champions League, four days before they attempt to avoid crashing out in the group stage of the current one. Barca have to win at Bayern Munich on Wednesday to be sure of going through.
This was hardly ideal preparation as a brilliant Betis counter-attack, finished by Juanmi in the 79th minute, consigned Barcelona to their fourth league defeat of the season.
"That goal annoyed me a lot because we had worked on those situations," said Xavi. "We didn't deserve to lose."
The result leaves Barcelona a daunting six points behind fourth-placed Atletico Madrid, who play a game in hand at home to Mallorca on Saturday.
They will also be 16 points behind leaders Real Madrid, if Madrid win at Real Sociedad while Betis moved into third to continue their excellent start to the campaign.
Gavi is unlikely to be available against Bayern after the midfielder had to be taken to hospital "according to protocol", said the club, for a head injury.
The 17-year-old was substituted in the first half after a Hector Bellerin clearance saw the ball strike his head from close range.
Xavi had started with two wins out of two in La Liga but even he admitted the results owed a lot to good fortune, with Espaynol and then Villarreal guilty of squandering chances.
In between, a goalless draw at home to Benfica in the Champions League exposed Barcelona's ongoing problems in front of goal and that was evident against Betis, who were relatively untroubled throughout.
Ousmane Dembele, who come on off the bench, posed the greatest threat while the 19-year-old Abde Ezzalzouli missed a golden opportunity to equalise late on, when the ball was cut back to him eight yards out. The youngster blazed over.
Minutes before, Betis showed far more composure to finish off a slick counter-attack.
Sergio Canales broke free down the right but the move appeared to have lost its momentum when Canales pulled back to Cristian Tello on the edge of the area.
Instead, Tello shifted the ball quickly left to the arriving Juanmi, who took one touch before sliding into the corner.
Earlier, Sevilla reduced the gap to Real Madrid to five points by beating Villarreal 1-0, with Lucas Ocampos scoring the winner in the first half.
Victory lifts Sevilla into second place, above Atletico Madrid, who play at home to Mallorca later on Saturday.
Villarreal have ambitions to challenge for the top four but they remain 12th after continuing a miserable run of form away from home. They are yet to win an away game in the league this season.
Ocampos gave Sevilla the lead in the 16th minute after Juan Foyth was dispossessed down the right, allowing Marcos Acuna to swing a cross to the back post, where Ocampos' header trickled in.
Rafa Mir thought he had added a second goal but was offside and then Sevilla spurned an excellent chance when they had a six against two on the counter-attack but failed to convert.
Villarreal should have made them pay in the second half only for Gerard Moreno to miss a sitter.
Dani Parejo's chipped ball was played across the box by Pervis Estupinan to the back post where Moreno, three yards out with the net gaping, somehow wafted wide.