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.
Barcelona and Real go head-to-head at the Nou Camp in the first El Clasico of the season next Saturday (15:00 BST).
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.
Ronald Koeman’s Barcelona – who face Hungarian side Ferencvaros in their Champions League opener on Tuesday (20:00) – are ninth, with seven points from their four games.