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.
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.
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 halftime and he repeated the task 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.
Atletico’s combative frontman Costa, who has been 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 re-start 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 crossed for Sergio Garcia to volley a superb second into the top corner.
Home fans continued to sing and applaud their side despite the setback, but the defeat left Malaga, who have not won in their last four league outings, in sixth place with 44 points.
Real Sociedad and Valencia won on Saturday to climb above them into fourth and fifth respectively.
Sociedad thumped Real Valladolid 4-1 to move on to 47 points and Valencia beat 10-man Real Betis 3-0 to climb on to 45.
Sevilla are 10th with 38 points after hammering 10-man Real Zaragoza 4-0 at home, when Alvaro Negredo’s 15th goal of the campaign made him the highest scoring Spaniard in La Liga.