Lionel Messi had a penalty saved as triple King's Cup holders Barcelona suffered a surprise 1-0 loss at city rivals Espanyol in a quarter-final first leg on Wednesday, ending an unbeaten run of 29 games in all competitions.
Espanyol's academy graduate Oscar Melendo crashed in the only goal of the game in the 88th minute after Messi had his spot-kick turned away by former Real Madrid goalkeeper Diego Lopez earlier in the second half.
Barca had not lost to Espanyol since 2009 and this was their first defeat by their local rivals in the Cup since 1970. The last game they had lost in any competition was in the Spanish Super Cup to Real Madrid on Aug. 16.
The second leg of the tie at the Nou Camp is on Jan. 25.
Elsewhere, Sevilla battled back from a goal down to win 2-1 at Atletico Madrid as Diego Simeone's decision to rest number one goalkeeper Jan Oblak in favour of Miguel Angel Moya backfired.
Moya clawed a cross into his own net in the 79th minute to cancel out Diego Costa's arrowed strike six minutes earlier, while Joaquin Correa struck the winner in the 88th to give under-fire new Sevilla coach Vincenzo Montella a much-needed victory.
Valencia also staged a late comeback to beat last year's runners-up Deportivo Alaves 2-1 at home. The visiting side went ahead through Ruben Sobrino in the 66th minute but Portugal international Goncalo Guedes levelled for Valencia in the 73rd.
Alaves defender Adrian Dieguez was dismissed in the 77th for picking up two bookings in the space of nine minutes, and Valencia striker Rodrigo Moreno took full advantage by shooting off the near post eight minutes from time.
Real Madrid visit Leganes in the other quarter-final first leg on Thursday.