Luis Suarez's fifth-minute opener was all Luis Enrique's men had to show for a dominant first-half display, during which the striker and Pedro both should have punished Rayo's high defensive line.
However, Barca found goals much easier to come by in the second half as they capitalised on Real Madrid's defeat at Athletic Bilbao on Saturday.
Gerard Pique doubled the hosts' lead in the 49th minute, before Tito was sent off for a foul on Suarez in the penalty area.
Messi's re-taken spot-kick put the result beyond doubt and he added two more goals to move past 40 for the sixth successive season and complete his 32nd treble for Barcelona.
Alberto Bueno converted a penalty for Rayo following the dismissal of Dani Alves, but Suarez rounded off the scoring late on with his 13th of the season.
A remarkable 15th win from 16 matches in all competitions puts Barca a point clear of Real at the Liga summit with El Clasico two weeks away.
Luis Enrique was without Sergio Busquets and Neymar through injury and suspension, so Xavi and Pedro started among five changes from Wednesday's Copa del Rey triumph at Villarreal, while Rayo boss Paco Jemez made four alterations to his line-up.
The Catalans, buoyed by Real defeat at San Mames, were quickly into their stride as Xavi's wonderful ball on the half-volley released Suarez, who confidently stroked home with the outside of his right foot.
Pedro spurned a chance to make it 2-0 following another fine pass from Xavi and, after Roberto Trashorras curled a free-kick just wide for Rayo, Barca went close again when Suarez's chipped pass found Messi, whose first-time lob drifted just wide.
Barca's dominance was made to count four minutes after the restart. Jordi Alba's free header hit the post and Pique was on hand to tap home the rebound.
Tito then hauled down Suarez in the box after 54 minutes and received a second yellow card as a result.
Messi's penalty was saved but a retake was ordered because of encroachment and he made no mistake at the second attempt, hammering a low shot into the bottom-right corner.
Barcelona pulled further clear in the 62nd minute when Suarez's smart turn and shot forced a save from Cristian Alvarez but Messi tapped in the rebound.
Alvarez produced a superb low save from a Messi free-kick two minutes later but the Argentina forward was not to be denied and completed his hat-trick in the 68th minute by latching onto a cross and showing great composure to dummy the goalkeeper before slotting in his 30th league goal of the campaign.
Barca's victory was soured somewhat when Alves was given a straight red after Leo Baptistao went down under his challenge and Bueno - the scorer of four goals in 15 minutes last weekend - dispatched the penalty for his 13th of the season.
Yet Suarez topped off a wonderful afternoon for the new league leaders by collecting Messi's pass before rounding Alvarez and slotting home in injury time.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.