This win takes Barcelona on to 84 points, three points more than second-placed Real Madrid.
It was Neymar who started the scoring by finishing off a fine team move by scoring from close range after Messi's pass in the 21st minute of the game.
However, Cedric Bakambu scored the equaliser for Villarreal in the 32nd minute.
The first of Messi's two strikes just before half time brought up a century of goals between himself, Luis Suarez and Neymar.
Suarez added a third from a tight angle in the 69th minute before Messi followed it up a first-half strike with a late penalty in the 82nd minute of the game. The penalty was Messi's 35th goal in La Liga this season.
The win takes Luis Enrique side on to 84 points, three points more than second-placed Real Madrid.