Sporting ruin Real home record
Real's failure at a stunned Bernabeu, three days before they host Tottenham Hotspur in the Champions League, spoiled their perfect home record of 14 wins in 14 this season and ended coach Jose Mourinho's own nine-year unbeaten run in home league games.
Barca then rubbed salt in their great rival's wounds in the late kick-off when Gerard Pique struck to earn three points at Villarreal and stretch their lead to eight points with eight matches left.
The Spain defender controlled a Sergio Busquets flick from a Daniel Alves corner on his chest in the 67th minute at the Madrigal and lashed the ball into the net from close range, sparking wild celebrations on the Barcelona bench.
"Mathematics say the league is not lost but objectively speaking if the gap goes from five to eight points we can say that it's almost impossible," Mourinho told a news conference.
"Luck is part of football and our opponent (Gijon) had it all and we had none."
Barca have 81 points from 30 games with Real on 73. Valencia climbed above Villarreal into third after Roberto Soldado struck four times against his former club Getafe in a 4-2 win.
Manu Del Moral put Madrid-based Getafe ahead in the 13th minute before Soldado, who joined Valencia at the end of last season as a replacement for the Barca-bound David Villa, scored four fine goals after halftime.
Adrian Sardinero netted a consolation in the 88th.
Real's joint La Liga top scorer Cristiano Ronaldo, in-form striker Karim Benzema and full-back Marcelo all missed the game against Gijon through injury, while midfielder Xabi Alonso was suspended, and Mourinho's side initially struggled to create chances against their obstinate visitors.
Forward Gonzalo Higuain, making his first appearance in four months after back surgery, squandered a fine opportunity on the hour when he blasted straight at goalkeeper Juan Pablo shortly after coming on as a substitute.
Gijon grabbed a surprise lead 19 minutes later when Miguel Angel de las Cuevas burst into the area from the left wing and struck a precise shot that beat goalkeeper Iker Casillas to his right and went in off the post.
In a frenetic final few minutes, Real were denied an equaliser by some desperate defending and Sami Khedira had an effort cleared off the line by a Gijon outfield player in the fourth minute of added time.
"A big part of the league has slipped away from us," Real's Spain defender Sergio Ramos said in a television interview.
Asked whether the defeat meant the end of their hopes of catching Barca, he added: "Being realistic, yes more or less. There are very few points left available.