The Barca captain finished on 25 goals, four clear of Real Madrid striker Karim Benzema.
The game was not of importance as Real clinched the La Liga title on Thursday.
Messi rounded the keeper to make it 2-0 and swept in a fifth – with teenager Ansu Fati, Luis Suarez and Nelson Semedo scoring the other goals.
Riqui Puig, Messi and Arturo Vidal all hit the woodwork before Fati opened the scoring.
This is the first time La Liga’s top scorer has managed fewer than 30 goals since Mallorca’s Daniel Guiza 12 years ago.
Barca, who only named five out of a possible 12 substitutes, host Napoli in the Champions League last-16 second leg on 8 August, having drawn 1-1 in Italy.