Oscar Melendo's late goal saw Espanyol snatch a 1-0 win and inflict a first defeat on Barcelona since August, after Lionel Messi failed to score a penalty in the first leg of the Copa del Rey quarter-finals.
A dominant Barca looked as though they would have to settle for a goalless draw after Messi saw his second-half spot kick saved by Diego Lopez on Wednesday, but worse was to come for the Liga frontrunners.
Espanyol caught them on the break late on and youngster Melendo provided a neat finish for his first senior goal, inflicting a first defeat on Barca since their Supercopa de Espana losses to Real Madrid.
Barca were on top from start to finish and created more than enough chances to take a victory back to Camp Nou.
But for all their control, the first half proved particularly frustrating, as clear-cut chances were hard to come by and, when the visitors did manage to craft an opening, the opportunity was wasted or saved.
They should have taken the lead just after the hour mark when Messi stepped up from 12 yards out, but Lopez rescued Espanyol with a brilliant save and Melendo – introduced from the bench – struck two minutes from time to secure an unlikely victory for the home side.
Barcelona did not have much trouble taking control of proceedings early on, as they enjoyed a monopoly on possession.
Chances were by no means a regular occurrence, however, with an eighth-minute Sergio Busquets effort that Lopez did well to parry away being the only opportunity at either end in the first quarter of the match.
Messi eventually burst into life in the 23rd minute and managed to charge through a crowd of players to get a shot away, only for Lopez to make light work of the effort.
At the other end, Barca looked almost too comfortable and such a relaxed approach nearly cost them, as Sergi Roberto gifted possession to Gerard Moreno and the forward fired just wide of the bottom-right corner.
The best chance of the half fell to Denis Suarez just before the break, though, as the midfielder received Messi's pass in the area and shot into the side-netting.
Barca's dominance continued into the second half and a moment of Messi magic forced Lopez into action, as the Argentinian flicked the ball over his head and drilled a volley towards the bottom-right corner from 18 yards, with the goalkeeper getting down to keep it out.
Valverde's frustration brought about the introduction of Ivan Rakitic and Luis Suarez from the bench and soon after the Uruguayan's entrance, Barca won a penalty.
Roberto found his way into the Espanyol area and went down under a clumsy Esteban Granero challenge, but Lopez brilliantly denied Messi's kick, getting down to his left and tipping it wide.
3 - Lionel Messi has missed more penalties than any other La Liga player this season in all competitions (three from six attempts). Strange. pic.twitter.com/rVgz6du5nY— OptaJose (@OptaJose) January 17, 2018
In an incident that will likely result in a sanction for Espanyol, Barca goalkeeper Jasper Cillessen appeared to get caught in the face by something thrown from the stands 13 minutes from the end.
Thankfully he was fine to continue and he made a strong save to push Marco Navarro's fierce free-kick effort over.
But he was helpless a few moments from the end when Melendo latched on to Navarro's well-placed cut-back and steered a cushioned left-footed finish into the bottom-left corner, ending Barca's 29-match unbeaten run.
|Wolfsburg preserve Bundesliga status after play-off win over Kiel|
|Zidane was my idol and always will be - Wijnaldum|
|Liverpool ready to fly out of the blocks in Kiev - Henderson|
|Montreal Impact 0 LA Galaxy 1: Ibrahimovic sent off for slapping opponent|
|Real Madrid v Liverpool: Salah, Ronaldo lead the line in combined XI|
|Bertens keeps hat-trick hopes alive in Nuremberg|
|Monfils and Mannarino fail to fly the flag in Lyon|
|Morata, Fabregas, Herrera and more in Spain´s World Cup rejects XI|
|Reina to face FIGC hearing|
|Emery set to be appointed by Arsenal - reports|
|LeBron ´appreciative´ of hometown effort to put up statue of him|
|Cazorla leaves Arsenal after injury nightmare|
|Derby´s Rowett seeks permission for Stoke talks|
|Messi physically and mentally ready for the World Cup, Sampaoli proclaims|
|Murray expected to return at Rosmalen Grass Court Championships|
|More to Madrid than just Ronaldo - Robertson|
|Wolff: Red Bull and Ferrari favourites in Monaco|
|Iniesta hailed by Xavi as ´the most talented player in the history of Spain´|
|If you Googled ´European nights´, Liverpool would be top result - Klopp|
|Icardi cut from Argentina World Cup squad|
|Test recall a ´fantastic surprise´ for Buttler|
|Klopp needs Premier League to be a Liverpool great – Johnston|
|Salah is ´definitely´ world´s best - Lovren|
|Rhinos captain Watkins ruled out for eight months|
|No clue - Klopp defiant over Can to Juventus claims|
|Younis tips Babar for Pakistan greatness|
|Germany squad numbers hint at World Cup good news for Neuer|
|WATCH: Moto3 rider makes spectacular jump over crashed rival|
|Leaving out Morata ´painful´ for Spain boss Lopetegui|
|Gustard to leave England role for Harlequins|
|Nainggolan retires from Belgium duty after World Cup snub|
|Spain striker Morata misses out on World Cup selection|
|LeBron or Kawhi could lead Lakers to the Finals - World Peace|
|Serena steps up Roland Garros training ahead of French Open|
|Nainggolan left out of Belgium´s World Cup squad|
|The long goodbye: Iniesta sits alone in Camp Nou after final Barcelona match|
|Wane to leave Warriors at end of season|
|Dr Fury will see you now - Tyson plans future career in medicine|
|Harden, D´Antoni rue ´soft´ Rockets performance in Warriors drubbing|
|Liverpool players can change their lives in Kiev, says Gerrard|
|Real Madrid v Liverpool: Can great deeds of the past fuel the bid for Champions League glory?|
|Wash your mouth out! - Curry´s expletive outburst earns scolding from mother|
|Rakitic lost for words as Iniesta heads for Barcelona exit|
|Conte: Chelsea must overhaul squad to change style|
|Johnston: Liverpool can´t lose Suarez, Coutinho and Salah!|
|Messi: I like Griezmann, he´s one of the best|
|Ohtani says he´s not good enough for Home Run Derby yet|
|Mendy: France are eyeing World Cup glory|
|Scott accepts two-week ban for Walker punch|
|Braves rally for six runs in the ninth to defeat Marlins|
|MLS Review: Red Bulls upstage Atlanta thanks to Wright-Phillips brace|
|Warriors breeze past Rockets in game three|
|We have a quality squad – Man City chairman hints at caution in transfer market|
|Wise cruises to maiden PGA Tour victory at Byron Nelson|
|Matic: United can fight for Premier League and Champions League with experience|
|Golden Knights GM on Stanley Cup Finals berth: I don´t know how we did it|
|I did a ´s*** job´ defending LeBron James – Morris|
|Dembele suffers sprained right ankle|
|We know Fellaini´s not going to renew with United – Mirabelli suggests Milan move|
|Cavs´ Lue not satisfied with just one win|
|They even whistled at Torres – Simeone backs Griezmann|
|I arrived as a boy, I leave as a man – Iniesta in emotional Barcelona farewell|
|Lingard: Wembley loss my worst feeling in football|
|Cahill: Conte uncertainty affecting Chelsea|
|Sarri has run out of time – Napoli chief De Laurentiis|
|Barca boss Valverde salutes departing Iniesta|
|I feel like I´ve been run over by a truck or had 15 pints - Crutchlow|
|Four sent off as Ajaccio win chaotic Le Havre play-off on penalties|
|Sweden win shoot-out to retain world title|
|De Vrij penalty was destiny for Inter - Icardi|