In the week he moved above rival Ronaldo with a sixth Ballon d'Or success, Messi showed why he was voted the world's best player with his impressive display at Camp Nou.
The 32 year-old scored two long-range goals in the first half and added a third seven minutes from time to make it 35 career hat-tricks in the Spanish top-flight.
That is one more than Ronaldo, who spent nine years with Real Madrid before joining Serie A giant Juventus in 2018.
Messi's first strike also saw him become the only player to net 10 or more goals in each of the past 14 seasons across Europe's top-five leagues.
Victory moved Barca back to the top of the table, with the champion above Madrid on goal difference ahead of the first Clasico of the season later this month.