The 26-year-old opened the scoring after 19 minutes to equal Paulino Alcantara's record of 369 goals in all competitions - including friendlies - for Barcelona. Alexis Sanchez and Andres Iniesta increased the hosts' advantage before the break.
Messi struck again in the second half to move onto 370 goals and become the club's undisputed top marksman, and then completed his treble with a simple finish in the 87th minute, after substitute Cristian Tello had rammed in the fifth goal.
There was still time for a seventh goal, however, Messi adding an assist to his goal haul by teeing up Pedro.
"We can't be carried away by today's game. Sometimes we lose points against teams that don't have as much money as us, but what we did do today is what we should always do: win and play well," said Barca coach Tata Martino afterwards.