Messi nets in 18th consecutive league match
The World Player of the Year was in devastating form along with David Villa, laying on the first for the Spain striker before Villa returned the favour twice, either side of the break.
Messi took his La Liga tally for the season to 42 goals and he last failed to find the net in the league at Celta Vigo on November 3.
Barcelona moved on to 74 points with 10 games left, ahead of champions Real Madrid in second who came from behind to beat Real Mallorca 5-2 at home on Saturday.
"We have recovered the intensity, we are in the Champions League quarter-finals, and now we welcome the break for the March internationals," Barca sports director Andoni Zubizarreta told Spanish television.
"Villa is feeling better every day on the pitch and he has fought really hard to be able to enjoy these moments."
Atletico Madrid were a point further back in third after Diego Costa scored twice in a 2-0 victory at Osasuna that kept them hot on the heels of their King's Cup final opponents.
Messi had already hit the crossbar with a free-kick when he laid on the opener for Villa to sweep in Barca's first after 25 minutes.
Villa, steadily cementing his place back in the side, released Messi on a breakaway to score just before half-time and he repeated the feat in the 57th, leaving the Argentine to burst past his marker and lob the keeper.
Substitute Raul Tamudo pulled one back for Rayo with his first touch in the 70th minute as chances fell to both sides in an open final period when Messi almost completed his hat-trick.
The only downside for Barca was a first-half hamstring injury to defender Adriano Correia that will rule him out for up to six weeks.
Atletico's combative front-man Costa, called up to Luiz Felipe Scolari's Brazil squad for their friendlies against Italy and Russia, finished off a counter-attack at the second attempt in the 35th minute at Osasuna.
Just after the restart he guided Koke's free-kick into the net from close range and he came close to completing a hat-trick in a typically bruising encounter in Pamplona.
Costa was forced to limp off with an ankle injury midway through the second half.
Earlier, Malaga's joy at qualifying for the Champions League quarter-finals for the first time was cut short when Espanyol condemned them to a 2-0 home defeat.
Manuel Pellegrini's side, on their first venture into Europe's top club competition, came back to beat Porto 2-1 on aggregate at a festive Rosaleda on Wednesday, but they struggled against a well-organised Espanyol.
Goalkeeper Willy Caballero, the rock upon which much of their success has been built this season, made a rare mistake when he fumbled a corner in the 49th minute and Diego Colotto volleyed the visitors in front against the run of play.
The hosts looked short of spark and were undone again in the 66th when Mubarak Wakaso burst down the left and crosse