Getafe striker Jaime Mata’s second-half penalty condemned Barcelona to their first La Liga defeat of the season.
Mata slotted his 56th-minute spot-kick into the bottom corner following Frenkie de Jong’s foul on Djene Dakonam.
Lionel Messi struck the post for Barcelona in the first half while Antoine Griezmann fired over at close range.
Juan Hernandez also hit the crossbar for Getafe with five minutes remaining.
Defending champions Real Madrid also suffered a shock 1-0 defeat by promoted Cadiz earlier on Saturday.
Anthony Lozano’s smart first-half finish gave the visitors their first win against Real in almost 30 years.
Zinedine Zidane’s side dominated possession but only managed two shots on target against a resilient Cadiz.
Barcelona and Real go head-to-head at the Nou Camp in the first El Clasico of the season next Saturday.
It is the first time since April 2003 that both Barcelona and Real have lost their respective league games prior to El Clasico.
Real sit top of La Liga despite their defeat, level on 10 points with Getafe, Cadiz and Granada.