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.
|Thiem keeps title defence on track, Monfils saves match point in Rio|
|Barcelona are great even without Neymar – Willian|
|Del Potro, Raonic progress at Delray Beach|
|Dolphins place franchise tag on Landry|
|Colts QB Luck ´extremely optimistic´ about shoulder rehab|
|Conte wants to see out Chelsea contract but has bags packed|
|A´s respond to Gruden´s belittling of Oakland|
|Yankees acquire Drury in three-team deal with Diamondbacks, Rays|
|Messi goal will give Barcelona more space at Camp Nou – Suarez|
|Serena Williams: I almost died|
|Conte defends ´incredible´ Christensen after Barcelona error|
|Bayern taking nothing for granted after 5-0 demolition – Heynckes|
|Valverde: Barcelona away goal not definitive for progression|
|Muller & Robben bemoan poor first half despite Bayern rout|
|Ivashka sets up Wawrinka Marseille meeting|
|Chelsea close to a perfect game against Barcelona - Conte|
|Defending for 90 minutes at Barcelona a ´suicide mission´ - Fabregas|
|Championship Review: Villa miss chance to move into promotion places|
|Messi ends his Chelsea hoodoo|
|Texans release all-time leading tackler Brian Cushing|
|Chelsea 1 Barcelona 1: Messi breaks Blues hoodoo to leave tie in the balance|
|Bayern Munich 5 Besiktas 0: Two-goal Muller inspires emphatic win after Vida red|
|Woods and Stricker appointed USA Ryder Cup vice-captains|
|Wales must attack Sexton and Murray - Gatland|
|De Vrij confirms intention to leave Lazio on free transfer|
|Sanchez move down to Champions League frustration at Arsenal - Mourinho|
|Mourinho suggests Pogba is fit to face Sevilla|
|Clinical Kerber strolls past Strycova in Dubai|
|AFC Champions League Review: Hulk & Oscar lead Shanghai, Jeonbuk Motors hit six|
|Cech expects Ospina to start for Arsenal in EFL Cup final|
|Gueye signs new Everton deal until 2022|
|FA charges Man City and Wigan for failing to control players|
|Aguero faces no action over Wigan fan incident|
|Martin released by Buccaneers|
|Las Palmas get green light to sign Viera replacement amid Nasri talk|
|De Kock, De Villiers & Du Plessis looking to Australia Tests|
|FA issues West Ham with anti-doping charge|
|Florenzi a doubt to face Shakhtar, confirms Roma´s Di Francesco|
|Maybe we ´lock him up or tie him up´ – Montella ponders how to stop Sanchez|
|French rugby crisis could last a long time - Magne|
|Pogba and Ibrahimovic train with Man Utd ahead of Sevilla tie|
|Zidane hints at resting Ronaldo for Real Madrid´s trip to Leganes|
|Biggar, Halfpenny and Williams return to Wales´ starting XV|
|Modric adds to Real Madrid injury worries|
|Braehmer pulls out of Super Series semi-final|
|Wolfsburg turn to Labbadia in fight for Bundesliga survival|
|Hales follows Rashid in signing white-ball deal|
|Wigan to investigate pitch invasion after win over Manchester City|
|Drogba ´couldn´t be more proud´ as son signs for Guingamp|
|Stones making no excuses for shock Wigan defeat|
|Bellugi scathing of Inter form and transfer policy|
|Ringrose could make Six Nations impact after comeback|
|Rakitic: I´ve not seen Messi in the gym this often|
|Winter Olympics 2018: Slovenian ice hockey star Jeglic sent home after positive doping test|
|Sevilla v Manchester United: Montella and Mourinho unified in pursuit of identity|
|Besiktas face Bayern test, Messi seeks to end drought - Champions League in Opta numbers|
|Jose Morais: The Mourinho acolyte bringing Barcelona to Barnsley|
|I´ve been bored – Ricciardo itching for start of F1 season|
|Rakitic: More to Chelsea than just Hazard|
|Hosmer agrees to eight-year deal with Padres|
|Cilic untroubled as Fognini battles in Rio|
|Sock, Chung through at Delray Beach|
|Klopp tactics behind my form – Salah|
|Young: Man United can win Champions League|
|Harper refuses to talk free agency, says he´s focused on this season|
|Messi is best but ´not invincible´, says Pedro|
|It´s a red card – Guardiola accepts Delph sending off amid City´s Wigan woe|
|Goffin hopeful of ´fast recovery´ after nasty eye injury|
|Aguero lashes out at fan as tempers flare after Wigan stun Man City|
|Grigg revels in dousing Manchester City´s fire|