The forward, who is joint top of the league's scoring charts this season with Chelsea's Cole Palmer missed FA Cup semi-final win over the Blues
Barca's captain coolly converted a penalty to put the champions ahead in the 23rd minute but gave away a foul in a dangerous area which led to Lucas Olaza levelling for Celta with an outstanding strike from a free kick in the 42nd.
But Messi restored Barca's lead right before halftime with a stunning free kick of his own, curling the ball into the top corner.
He conjured up an almost identical strike at the start of the second half to complete his treble and match Cristiano Ronaldo's record of 34 hat-tricks in Spain's top flight.
Barca lead the standings on 25 points after 12 games, level with second-placed Real Madrid who eased to a 4-0 win at Eibar.