Real Madrid lead Barca on goal difference at the top of the table after Cristiano Ronaldo became the Spanish giants' all-time leading scorer in a comfortable 3-0 win over Levante earlier on Saturday.
Javi Guerra had given Rayo a shock lead at the Camp Nou, but Neymar twice converted from the penalty spot after he had been brought down to give the hosts a half-time lead.
The Brazilian then struck twice in a minute after the break and teed up Luis Suarez to rifle home a fifth before Jozabed pulled a goal back for Rayo as Barca got back to winning ways after a 2-1 defeat at Sevilla last time out.
"I'm very happy for the victory and how we played. Everyone deserves congratulations," Neymar told Canal Plus.
Also Read
"It was very difficult, they have quality players that play their football. We struggled a bit, but we did our job."
Barca should have had the game well wrapped up by half-time against an incredibly open Rayo defence as Tono made brilliant one-on-one saves from Ivan Rakitic and Suarez in the first 10 minutes.
However, it was the visitors who took the lead on 14 minutes when Manchester United reject Bebe's driven cross was turned in by Guerra.
Neymar had the ball in the net again moments later, but the goal was ruled out as Suarez was adjudged to have interfered with Tono's view from an offside position.
Barca were soon in front as an outrageous piece of skill from Neymar provoked Nacho into committing another penalty and this time Neymar slotted the ball to Tono's left.
Rayo had chances to draw level again early in the second period as Claudio Bravo did brilliantly to twice deny Guerra from close range.
And it was roles reversed for the fifth as Neymar's cross was thumped home on the volley by Suarez.