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.
|Thunderstorms push Andalucia Valderrama Masters into reserve day|
|Edmund masters Monfils to claim maiden singles title|
|Kohli and Rohit fire India to comprehensive ODI win|
|Manchester United didn´t play - David Luiz blasts Mourinho tactics|
|Svitolina out to silence ´haters´ in Singapore|
|Emre Can facing surgery on thyroid problem|
|Tsitsipas claims maiden ATP crown in Stockholm|
|Mariners boss Mulvey knows nothing of Bolt contract offer|
|WATCH: Vinicius Junior scores free-kick - then sees red!|
|Gronkowski ruled out of Bears clash|
|Khachanov enjoys home comforts with comprehensive Kremlin Cup win|
|Isner wants Wimbledon tie-break rule named after him|
|Hummels lauds ´outstanding´ Lewandowski|
|Liverpool´s defensive improvement no accident – Gomez|
|Pliskova overpowers defending champion Wozniacki in Singapore|
|Marquez dislocates shoulder celebrating MotoGP title|
|Henry taking positives from opening Monaco defeat|
|A-League Review: Mariners held as Bolt considers move|
|Dominant Svitolina ends Kvitova hoodoo in Singapore|
|Pereira warns Juventus to expect ´pumped up´ Manchester United|
|D´Antoni backs NBA to ´sort out´ Lakers-Rockets brawl|
|Mixed feelings for champion Marquez after Dovizioso crash|
|Bolt offered contract by Central Coast Mariners|
|Anthony accuses Rondo of spitting after Lakers-Rockets brawl|
|Martial insists he has good relationship with Mourinho|
|Bautista to replace Lorenzo at Phillip Island|
|Emery wanted Lacazette at Paris Saint-Germain|
|Wallabies centre Hodge suffers fractured ankle|
|Koepka claims top ranking with CJ Cup win|
|Dramatic Dovizioso crash gifts Marquez MotoGP title in Japan|
|LeBron´s home debut ends in defeat, Walker makes NBA history|
|Rondo, Ingram and Paul exchange punches in Lakers-Rockets clash|
|Dodgers to face Red Sox in World Series after beating Brewers|
|Valverde doesn´t care about extending Barca contract|
|Qualifying speed a ´positive surprise´ for Ferrari´s Vettel|
|I was in a different headspace – Hamilton revels in Austin pole|
|Barcelona can cope without Messi – Pique|
|Allegri: Juventus abandoned Genoa clash|
|Sale: Hospital visit was because of belly button ring|
|Valverde accepts Barcelona will miss Messi|
|No Messi or Ronaldo in El Clasico for first time since 2007|
|Barcelona have not won a Clasico without Messi since his debut|
|Ramos calls for Real Madrid unity after latest loss piles pressure on Lopetegui|
|Hamilton has title in sights after storming to Austin pole|
|Inter, El Clasico and more - the games Messi will miss with broken arm|
|End of Messi-Ronaldo duel good for LaLiga - Simeone|
|Messi out of Clasico with fractured arm|
|Awesome Ashton marks Sale bow with hat-trick|
|Klopp hopes for positive Henderson prognosis amid Liverpool injury issues|
|Benitez ´convinced´ Newcastle can survive despite seventh defeat|
|Barcelona 4 Sevilla 2: Messi injured but champions go top|
|Kovac relieved by Bayern´s timely victory|
|Strasbourg 2 Monaco 1: Sy howler and Grandsir red card cost Henry in first match|
|Leicester City defender Chilwell signs new six-year contract|
|PSG´s Tuchel hopes Verratti and Di Maria can face Napoli|
|Liverpool star Salah had no fear during scoring drought|
|Alonso´s 2019 plans not damaged by McLaren´s IndyCar decision|
|Edinburgh outclass troubled Toulon, Wasps and Bath play out thrilling draw|
|Barca concern as Messi substituted with worrying arm injury|
|Howe: South coast derby draw a fair result|
|Our heads were in Manchester – Allegri left fuming at Juventus´ loss of focus|
|Derby County 2 Sheffield United 1: Marriott blunts Blades with 77th-minute winner|
|We have so many problems – Jokanovic alarmed by Fulham defensive woes|
|Huddersfield Town 0 Liverpool 1: Salah snaps winless streak|
|Pellegrini ruing injuries after Yarmolenko hurts ankle|
|Villarreal 1 Atletico Madrid 1: Simeone´s side denied LaLiga top spot|
|Gracia: Not easy to dominate Wolves like that|
|Isner´s Finals hopes hindered by Stockholm defeat|
|Dyche incredulous at refereeing decisions in Man City thrashing|
|Juventus 1 Genoa 1: Champions´ winning run ends despite record Ronaldo goal|