Lionel Messi missed a penalty as Barcelona's 29-match unbeaten record came to a shuddering halt at rivals Espanyol.
Messi saw his spot-kick saved by Diego Lopez before Espanyol substitute Oscar Melendo scored a memorable winner two minutes from time in the first leg of their Copa del Rey quarter-final.
Barcelona went into the game on the back of an impressive comeback victory over Real Sociedad in La Liga and eager to extend their undefeated run to 30 games. But Melendo's late heroics secured a memorable 1-0 win for the hosts, their first over Barca since 2009.
As expected there was no Philippe Coutinho in Barca's line-up but a mounting injury list, which has accounted for France forward Ousmane Dembele, meant Messi did start. The Argentine was involved immediately, breaking towards goal before he was hauled down by Javi Fuego 25 yards out, and then sending the free-kick over the crossbar.
Gerard Pique had the ball in the net after half an hour, heading in off a post from a corner, but it was ruled out by a linesman's flag.
Denis Suarez should have given Barca the lead two minutes before half-time when sent clean through by Carles Alena but he dragged his shot into the side-netting.
Worse was to come for Barca midway through the second half when Esteban Granero slid in on Sergi Roberto in the area to give away a penalty. Messi stepped up but saw his spot-kick superbly saved by Lopez, diving to his left.
And Barca's misery was complete when Marc Navarro pulled the ball back to Melendo, with the 20-year-old slotting a first-time finish into the bottom left corner for a dramatic winner.
Elsewhere on Wednesday night, Sevilla won 2-1 at Atletico Madrid in the first leg of their quarter-final tie.
Diego Costa gave Atletico the lead in a game marred by pre-match violence, but a Miguel Angel Moya own goal in the 79th minute levelled the game before Joaquin Correa struck a late winner for Sevilla.
And Valencia also came from behind to beat Alaves 2-1. Goncalo Guedes cancelled out Ruben Sobrino's opener for the away side, who then saw Adrian Dieguez dismissed for a second bookable offence. Rodrido struck in the 82nd minute to give Valencia the advantage in the tie.