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 then increased the hosts' advantage before the break as Barça set about getting their title defence back on track following last weekend's shock 1-0 defeat at Real Valladolid.
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, however, Messi adding an assist to his goal haul by teeing up Pedro.
Barça remain third in the table and four points behind leaders Real Madrid, but will have the chance to cut the gap with their arch-rivals at the Bernabeu in a week's time.
Sevilla and Sociedad boost Champions League hopes
In the chase for the fourth and final UEFA Champions League spot, Real Sociedad and Sevilla both boosted their hopes of catching Athletic Bilbao - in action at sixth-placed Villarreal on Monday - with home wins.
Sociedad are five points behind their Basque rivals Athletic after beating Valencia 1-0 thanks to Imanol Agirretxe's 61st-minute strike, while Sevilla are two points further back following their 4-1 drubbing of Valladolid.
A brace from Kevin Gameiro, one a penalty, plus further goals from Ivan Rakitic - also from the spot - and Diogo Figueiras earned them victory and improved their winning streak in La Liga to four matches.
It was also the perfect response to Thursday's 2-0 home defeat to arch-rivals Real Betis in the first leg of their UEFA Europa League last-16 tie.
Valladolid netted a consolation at the Ramon Sanchez Pizjuan through Javi Guerra but it did little to affect the outcome as his side stay in the relegation zone.
In Sunday's other game, Betis followed up their derby success with a 0-0 draw at Elche but still remain seven points adrift at the foot of the table.