With the gap earlier cut to four points after Atletico Madrid beat Leganes 1-0, Barca went into the contest under pressure and were a long way from its best in the first half.
And Rayo threatened to hand Atleti's prospects of overhauling the defending champions a boost when they opened the scoring through Raul de Tomas' fine strike.
However, Gerard Pique levelled seven minutes in the 38th minute before Lionel Messi's penalty and a late third from Luis Suarez ensured Barca still have plenty of breathing room at the summit.
Rayo started brightly and was denied what looked a decent shout for a penalty when Pique appeared to pull down De Tomas just inside the area.
Only the fine reflexes of Stole Dimitrievski prevented Luis Suarez from opening the scoring as the Macedonia international turned his low effort behind, and the Camp Nou crowd was then silenced as his counterpart at the other end was beaten.
De Tomas cut in from the left and took on Pique and Nelson Semedo before unleashing a powerful bending effort beyond Marc-Andre ter Stegen and into the bottom-right corner.
Pique wasted a gilt-edged chance just after the half hour, sending a close-range header well wide, but atoned for that miss as the centre-back nodded home Messi's right-wing free-kick.
And the turnaround was completed six minutes after the restart, Messi casually beating Dimitrievski from 12 yards, punishing Jordi Amat for an ill-advised challenge on Semedo on the right side of the box.
Jose Pozo flashed an effort wide as Rayo sought a leveller and, though Alex Moreno did well to head a seemingly goal-bound Messi free-kick behind, Rayo could not prevent Suarez from tapping in a third after combining superbly with Ivan Rakitic.