Real Madrid's 40-match unbeaten run was brought to an end as ex-Manchester City forward Stevan Jovetic scored a dramatic stoppage-time winner for title rivals Sevilla.
Cristiano Ronaldo had put the visitors ahead with a penalty after Dani Carvajal had been fouled by Sevilla goalkeeper Sergio Rico.
Sergio Ramos' late own goal against his former club levelled the scores.
Substitute Jovetic beat Kaylor Navas from distance to win it.
Navas, who appeared to be out of position, did get a hand on Jovetic's effort but could not stop it from hitting the net.
Real's first defeat since 6 April means their lead at the top of La Liga has been cut to one point, although Zinedine Zidane's side have a game in hand over their title rivals.
Sevilla move above Barcelona to second in the table.
Relive the action from Seville
Seven minutes that changed the title race
All seemed to be going smoothly for Zidane's side as Ronaldo silenced a hostile crowd by slotting his side ahead from the spot.
Karim Benzema had already blazed a close-range chance over the bar yet Ronaldo's goal put Real, chasing a first La Liga title since 2012, in command.
Their downfall started when Ramos, who had upset Sevilla fans three days earlier with his goal celebration in their Copa del Rey last-16 tie, headed into his own net while attempting to clear Pablo Sarabia's set-piece.
Real were rattled and Jovetic's fine strike after Real had lost the ball from a throw-in was celebrated wildly by the home fans in the Ramon Sanchez Pizjuan.
Zidane's side are still well placed to be crowned champions of Spain for the first time in five years.
Yet this result will fill Barcelona with hope of overtaking their arch-rivals, with just two points separating them as the season approaches its midway point.
Will Sevilla be celebrating in May?
It is 71 years since Sevilla won La Liga but Jorge Sampaoli's side have very real hopes of ending that drought this season.
The Argentine, who masterminded Chile's 2015 Copa America success, has proved a revelation since taking charge last summer.
This was their 12th win in 18 league games under the 56-year-old - and by far the most eye-catching.
Their success has largely been down to a combination of hard work and determination, ingredients which have also earned them a passage into the last 16 of the Champions League and a meeting with Leicester City.