Jaime Mata scored the only goal from the penalty spot early in the second half and that was enough to lift Getafe up to second, level on points with leaders Real Madrid, who were beaten at home by Cadiz earlier on Saturday.
Lionel Messi hit a post for Barca in the first half, but it was a frustrating evening for the Catalans and Getafe also hit the woodwork in the closing stages.
Barca's first defeat of the season under head coach Ronald Koeman leaves them ninth in the table, three points adrift of Madrid with a game in hand.
Getafe midfielder Nemanja Maksimovic forced Barcelona goalkeeper Neto into a save and Messi struck a post with a low curling effort.
But first-half chances were few and far between. Antoine Griezmann blazed over the crossbar having been set free by teenager Pedri and Clement Lenglet failed to make contact with Messi's excellent cross.
Barca dominated possession, but were under constant pressure as Getafe hustled and harried them out of their stride.
The pattern continued in the second half as Messi looked to orchestrate by falling deeper, but it was the hosts who broke the deadlock via Mata's penalty in the 56th minute.
The host went even closer soon after as Cucho Hernandez burst clear and fired against the crossbar and despite six minutes of added time, Barca could not find a way back.