The Blaugrana could mathematically seal the title in the El Clasico, which will be played in two weeks at the Nou Camp. Getafe remained sixth with 44 points, the same number as Celta.
This is the Catalan team's first triumph at the "Colosseum" since 2019, when they enjoyed an identical result.
The guests took the lead at the end of the 45th minute, when Fermin Lopez scored on a pass from Pedri.
The final score was set up by substitute Marcus Rashford after a counterattack and a pass from Robert Lewandowski.
Barca will play Osasuna in the next round, while Getafe will host Rayo Vallecano.