Luis Enrique's side had to come from behind to get the win on Sunday night, with its talisman scoring the winning goal.
Barca twice fell behind at Camp Nou but fought back strongly to seal all three points and end Villarreal's 18-match unbeaten run in all competitions.
It looked as though it might extend that sequence when on-loan Real Madrid man Denis Cheryshev put Villarreal ahead in the 30th minute, but Neymar brought the host level on the stroke of halftime.
Luciano Vietto restored the visitor's lead soon after the break thanks to a Gio dos Santos assist, but goals three minutes apart from Rafinha and Messi put Barca in control.
Rafinha's effort was a scrappy one, but Messi's - his 22nd goal in La Liga this season – was typically anything but as he caressed the ball into the net from the edge of the box.
The win moves Luis Enrique's side back to within one point of fierce rival Real Madrid at the Liga summit, after Carlo Ancelotti's side thumped Real Sociedad 4-1 on Saturday.
Barca made a bright start, as Sergio Asenjo clawed away Luis Suarez's first-time effort from the edge of the box, before the Uruguayan shot narrowly wide of the right-hand post.
For all Barca's pressure, Villarreal took a surprise lead on the half-hour mark with its first attack of note.
A loose ball on the edge of the box fell to Mario, whose wayward shot was heading well wide of the target until Cheryshev stuck out a leg and diverted the ball goalward, wrongfooting Claudio Bravo.
Just when it appeared the visitor would reach the interval unscathed, it came undone in the final minute of the half as Neymar converted after Asenjo parried Rafinha's initial effort back into danger.
Far from being downhearted by that blow, Villarreal retook the lead in the 51st minute.
Gerard Pique's mistake allowed dos Santos to race to the byline and cut back inside his former Barca colleague before squaring the ball for Vietto to sweep home from close range.
Any worries Luis Enrique had were soon eased though as Barca roared back.
First, Suarez crossed for Messi whose header was blocked in front of goal, but Rafinha nipped in to smash home his first Liga goal for Barca on the rebound.
Two minutes later, Jordi Alba's pass found Suarez, who again fed Messi, only this time the Argentina star was not to be denied, curling a delightful right-foot finish into the top corner from 18 yards.
In a breathless period of play later, Villarreal's Victor Ruiz had a goal ruled out for offside before Barca broke upfield at pace.
Neymar's appeals for a penalty were turned away as he tumbled over Asenjo's challenge one-on-one, and Suarez inexplicably headed wide from point-blank range as play went on.
That miss proved academic, however, as Barca comfortably saw out the game to record its eight successive victory in all competitions.