Atletico Madrid cut the gap to four points ahead of kickoff in Catalonia by overcoming Leganes, but Barca came from behind to beat Rayo on home soil courtesy of goals from Gerard Pique, Lionel Messi and Luis Suarez.
Ernesto Valverde's side will now switch their attention to the Champions League as they prepare to welcome Lyon for the second leg of their last-16 tie on Wednesday night.
Barca's first-half chance of the night arrived in the 10th minute when a dangerous free kick from Messi caused a problem inside the Rayo box, but the away side's goalkeeper Stole Dimitrievski just about did enough to clear.
The hosts were the team forcing the issue as play developed in Catalonia, but Rayo - in their 5-4-1 shape - were proving difficult to break down as they crowded their own half of the field.
Luis Suarez had a curling effort deflected wide of the post in the 18th minute, before Messi saw a header saved by the Rayo stopper five minutes later.
It was the visitors that took a shock lead at Camp Nou, however, when on-loan Real Madrid striker Raul de Tomas worked some space outside the Barca box before feeding a wonderful effort into the bottom corner.
De Tomas has been far and away Rayo's best player this season and his goal shocked Barca into action.
Pique should have headed the home side level in the 32nd minute when he met a free kick from Messi, but the Spaniard could not make proper contact and Rayo escaped a dangerous moment.
Luis Suarez and Messi were the two attempting to make things happen for the champions, but there was not too much from Philippe Coutinho, who continues to struggle in a Barca shirt.
Valverde's side were level in the 39th minute, however, when Pique made up for his earlier miss by rising high inside the Rayo box to head a Messi free kick past Dimitrievski, who got nowhere near the ball.
Messi had a golden chance to make it 2-1 Barca in the latter stages of the first half, but the Argentine - having danced into a shooting position - was denied by a last-ditch clearance from Alejandro Galvez.
Rayo made a positive start to the second period, but the visitors conceded a penalty in the 50th minute when Jordi Amat brought Nelson Semedo to the deck, and Messi stepped up to send the resulting spot kick into the corner.
Barca - now 15 points clear of third-placed Real Madrid - were utterly dominant in the period that followed as they looked for the third, with Rayo retreating deeper and deeper in a bid to stay in the contest that they once led.
Dimitrievski had to keep out a low Messi effort just before the hour, before the Argentine had a free kick headed over the Rayo crossbar by the retreating Alex Moreno 10 minutes later.
Luis Suarez almost found Coutinho for a tap-in in the 72nd minute, but Santiago Comesana was on hand to make the clearance as Rayo stayed in the match approaching the final 15 minutes.
Barca made sure of the points in the 82nd minute, though, when Ivan Rakitic's clever pass found Luis Suarez, who simply could not pass up the chance to convert from close range.
The champions had a couple of half-chances to add a fourth late on, but it finished 3-1 as they strengthened their grip on first position in the table, leaving Rayo camped inside the relegation zone in the process.
BARCELONA (4-3-3): Ter Stegen; Semedo, Pique, Umtiti, Alba; Vidal, Busquets (Malcom 85'), Arthur (Dembele 46'); Coutinho (Rakitic 80'), L Suarez, Messi
RAYO VALLECANO (5-4-1): Dimitrievski; Advincula, Velazquez, Galvez, Amat (Pozo 64'), Moreno; A Garcia (Embarba 80'), Comesana, Imbula, Bebe; De Tomas body check tags ::