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.
|Henderson still confident of Liverpool success|
|Sporting Kansas City 0 Columbus Crew 0: 10-man visitors battle to MLS draw|
|Inglis to captain new-look Maroons, Boyd and Scott axed for Origin I|
|Neymar labels Real Madrid links ´nonsense´|
|Koepka ready to turn seconds into wins|
|Rose ´really proud´ of Fort Worth Invitational win|
|Paul a ´game-time decision´ for series decider, says Rockets coach D´Antoni|
|Egypt president wishes Salah speedy recovery|
|Bonucci: Balotelli has matured|
|Ranieri backs Sarri to succeed at Chelsea|
|Konta admits to doubts after another early Roland Garros exit|
|Warriors´ Iguodala, Looney listed as questionable for game seven|
|Zverev batters Berankis, Goffin back from the brink in Paris|
|Rose cruises to victory at Colonial|
|Neymar: I´m not at 100 per cent yet|
|Toulouse confirm Ligue 1 survival with win over Ajaccio|
|I know what I´ve achieved - Bale not worried about plaudits as he looks to the future|
|Ostapenko ´angry´ after Roland Garros exit, Venus Williams falls at first hurdle|
|Barcelona B relegated to Spain´s third tier|
|Rayo Vallecano win promotion to LaLiga|
|Tarkowski leaves England camp for hernia surgery|
|Ramos ´quite clever´ but Salah injury not to blame for final defeat, insists Robertson|
|WATCH: Ricciardo takes wide receiver role on yacht for Tom Brady pass|
|Until next year – Ronaldo drops new future hint as Real Madrid celebrate with fans|
|Froome stunned by Giro triumph|
|The Triple Crown: Froome´s Grand Tour glory in numbers|
|Hannover sign Wimmer on season-long loan|
|Inter powerless to stop Icardi exit, admits Spalletti|
|Ashton makes England statement with Barbarians hat-trick|
|Watson masterclass seals third IPL title for Super Kings|
|Kozlova ends Ostapenko´s Roland Garros reign on day one|
|Imperious Zverev breezes into second round|
|Froome wins Giro d´Italia to complete Triple Crown|
|Stricken Salah confident over World Cup hopes|
|Verstappen highlights change in approach amid Rosberg criticism|
|Strinic claims three-year deal at Milan|
|Napoli captain Hamsik considering China offer|
|Chinese outsider Wang shocks Venus Williams in Paris|
|Redemption two years in the making - Ricciardo revels in Monaco glory|
|Flawless Molinari holds off McIlroy at Wentworth|
|Karius ´infinitely sorry´ but thanks Liverpool fans for support|
|Root and Bayliss dismiss ´outrageous´ fixing allegations|
|Giggs: Bale the best Welsh player I´ve seen|
|Ricciardo ends Monaco hoodoo despite mechanical issue|
|Lyon star Fekir denies being close to Liverpool switch|
|Pogba: I learned a lot from Abou Diaby|
|Where next for Real Madrid stars Ronaldo and Bale?|
|Shingler and Hewitt out of Wales tour|
|Kyrgios pulls out of French Open|
|Khan wants to bow out by winning blockbuster Brook fight|
|Is winter coming? Game of Thrones stars descend on Monaco|
|Root urges England´s batsmen to ´find a way´|
|Lovren, Van Dijk absolve Karius of blame|
|We all know where our nipples are - Hansen welcomes tackle trial|
|Rooney would thrive in MLS, says DC United boss|
|Pakistan complete demolition of sorry England|
|Curry, Durant reveal the secret to Thompson´s success|
|Salah will miss World Cup, claims Saudi sports administrator|
|Deschamps marvels at Zidane´s incredible Champions League success|
|FIA satisfied Ferrari ´inside the rules´|
|NSW Origin hopeful Moylan pulls the strings for rampant Sharks|
|Champions League blunders will stay with Karius - Clemence|
|Warriors assuming Iguodala won´t play game seven, Kerr says|
|Lampard confirms Derby talks over vacant managerial position|
|French Open 2018: The science behind Nadal´s clay-court dominance explained|
|Walsh to continue as Bangladesh head coach|
|Bale makes emphatic point after Champions League omission|
|Casemiro: I bet Ronaldo stays at Madrid|
|Brewers pull away for blowout win over Mets|
|Warriors´ outburst sinks Rockets, forces game seven|