Portuguese forward Francisco Trincao put Barca in front after a cut-back from 18-year-old debutant midfielder Ilaix Moriba and Messi thought he had doubled the lead later on when knocking in on the rebound but the goal was ruled out for a marginal offside against Antoine Griezmann.
Messi then took matters into his own hands from outside the area and thumped the ball off the far post with such venom that it landed just inside the opposite post.
Alaves' Luis Rioja pounced on a mistake by Ilaix to reduce the deficit in the second half but Barca came roaring back with a second strike from Trincao, another long-range missile from Messi and then a fifth goal crafted by Messi and Griezmann and finished off by left back Junior Firpo.
Barca had suffered a painful 2-0 defeat to Sevilla in Wednesday's Copa del Rey semifinal first leg and coach Ronald Koeman rotated his side to make for fresher legs for Tuesday's first leg at home to PSG.
He rested Jordi Alba and started without Sergino Dest, Ousmane Dembele and Pedri but there was no rest for Messi, who unleashed a ferocious shot for his first goal after his earlier strike had been cruelly chalked off.
He also sparked the move for Barca's third goal, racing on to a through ball and attempting to round keeper Fernando Pacheco, who succeeded in snuffing out Messi but could only parry the ball into the path of Trincao, who tucked it into the unguarded net in the 74th minute.
Messi was hungry for a second goal of his own, however, and got one less than 60 seconds later, dribbling past two defenders outside the area and rattling a left-footed shot into the far corner.
Now toying with his prey, he released Griezmann with a delicious chipped pass and the Frenchman sent in a low cross for Firpo to complete the thrashing.
Trincao later netted what would have been his hat-trick goal but was denied by the offside flag.