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.
|Injury rules Bernardo Silva out of Poland clash|
|Lamar Jackson debut start ´spectacular´ - Ravens coach Harbaugh|
|Babar run out the turning point, laments Sarfraz|
|West Ham boost London Stadium capacity to 60,000|
|A great advertisement for Test cricket - Williamson revels in stunning win|
|Van Dijk one of the world´s best - Klaassen|
|Floersch had ´angel on her shoulder´ in horror crash|
|Gascoigne charged with sexual assault|
|I am going to stay at Chelsea and fight, insists Giroud|
|Hansen to make announcement on All Blacks future|
|I have reached the top by joining Chelsea - Sarri|
|Bonucci tells Italy boo boys to ´live with less envy´|
|Dramatic Pakistan collapse gives Stead first New Zealand Test win|
|Button enjoying racing for first time in years|
|Dortmund chief not planning Pulisic sale|
|Theismann: Smith leg break ´heart-wrenching´ to watch|
|Wolves defender Jonny suffers knee injury|
|Holmes to meet with Sharks amid NFL switch talk|
|LeBron made 51 points ´look easy´, says Walton|
|McGuire signs four-year deal with Cowboys|
|Bears beat Vikings to extend NFC North lead|
|Peng overcomes Davis in Houston final|
|Kerr says this has been his toughest stretch as Warriors coach|
|LeBron scores 51 in Lakers´ win, Warriors fall to Spurs|
|Win more than Djokovic? Let´s chill out – Zverev|
|Steelers´ rally highlights wild day of close, last-minute finishes|
|Modric not worried about Ballon d´Or|
|Saints pull away for blowout victory over Eagles, extend winning streak to nine|
|Martinez laments loss of control by Belgium|
|Logano claims first NASCAR Cup championship|
|Luis Enrique delighted with attitude of Spain´s squad|
|Stevens tells Celtics to get ´tougher´|
|Griezmann: Being Messi´s lieutenant played a part in rejecting Barcelona|
|Curry proud of how Warriors handled Green-Durant incident|
|Courtois: Belgium thought Nations League job was done|
|Howell ends 11-year title drought to deny record-breaking Rodgers|
|Robben dismisses Bayern title talk|
|Huge blow for Redskins as QB Smith breaks tibia and fibula|
|Switzerland 5 Belgium 2: Seferovic treble crowns incredible comeback|
|Titans DC Pees taken to hospital during Colts game|
|Spain 1 Bosnia-Herzegovina 0: Debutant Mendez spares Morata´s blushes|
|Peterson goes sixth on rushing touchdowns list|
|Titans QB Mariota suffers elbow injury|
|Djokovic hails much-improved Zverev|
|Arnautovic refuses to discuss West Ham future after Austria win|
|Redskins QB Smith carted off after gruesome ankle injury|
|Jaguars shut down Jalen Ramsey trade rumours|
|Classy Zverev revels in victory, hails defeated Djokovic|
|Forget the Nations League was ever invented, jokes Northern Ireland boss O´Neill|
|Magnificent Zverev claims ATP Finals title|
|Mahrez double fires Algeria to 2019 AFCON|
|Mbappe hoping for French winner of Ballon d´Or|
|Northern Ireland 1 Austria 2: Last-gasp winner denies hosts maiden Nations League point|
|Teenager admits assaulting Wales great Thomas|
|Browns deny Condoleezza Rice is candidate for head coaching job|
|Koeman: Netherlands not favourites for Germany clash|
|Dalic ´not sad´ but blames fatigue for Croatia relegation|
|Proud Southgate hails England hero Kane as world´s best goalscorer|
|Last-gasp Exeter penalty try shatters Bristol|
|Mbappe dismisses talk of Cavani-Neymar rift|
|Keita will do ´great things´ for Liverpool – Mane|
|Mourinho needs time to fix Manchester United - Veron|
|Southgate sees progress as England reward loyal support|
|Miller hungry to ´knock out a Brit´ after Dinu demolition|
|Yasir, Hasan put Pakistan in control with five-wicket hauls|
|England´s resilience delights Kane as Three Lions secure Nations League Finals spot|
|Kane proves Nations League importance to England in Wembley decider|
|Muller, Hummels still important for Germany, says Low|
|Tevez in line for start in Copa Libertadores final second leg|
|England 2 Croatia 1: Kane able to secure Nations League Finals spot|