The Liga giants had their three-prong attack to thank as they secured an important victory over Jose Ramon Sandoval's men to move closer to their rivals at the top of the table
An impressive double from Alexis Sanchez gave Pep Guardiola's side the lead before David Villa found the back of the net just before half-time. Lionel Messi added a fourth four minutes after the restart to secure the win as Real Madrid's lead was cut to three points, with Jose Mourinho's men having played a game less.
The victory also ensured it was the 11th Liga game in a row at Camp Nou where the Catalan club had kept a clean sheet, a new record in Spain.
The match, brought forward due to Barca's participation in the Club World Cup next month, had a frantic opening in which the home side came close to opening the scoring as early as the second minute.
Andres Iniesta spotted Davis Cobeno off his line and the midfielder's audacious effort from 40 yards out had the goalkeeper backtracking, and he eventually had to dive at full stretch to turn the ball around the post for a corner.
Despite not being at their flowing best, Pep Guardiola's men took the lead in the 29th minute through a moment of magic from Sanchez. The Chilean received the ball from a Xavi pass on the left-hand side of the box, before cutting in and curling a delightful effort into the far top corner for his second Liga goal of the season.
On 41 minutes, the home side doubled their lead and it was Sanchez again who found the back of the net, via an inadvertent piece of skill from Xavi. Lionel Messi's clever through pass found the 31-year-old midfielder who flicked the ball with his heel into the path of Sanchez, to sweep home from 12 yards out.
Two minutes later the champions added a third to put the result beyond doubt before the half-time whistle had been blown. Gerard Pique's barnstorming run into the Rayo final third saw the former Manchester United defender slide the ball to Alves, who then squared it to David Villa, the Spaniard placing the ball into an empty net from close range.
The home team made it four on 49 minutes with Messi grabbing his 16th Liga goal of the season. The Argentine controlled Alves' pass on the right wing before pacing past Javi Fuego and sliding the ball past Cobeno from a narrow angle.
Villa nearly made it five in the 70th minute when he controlled a long ball before attempting to lift over the onrushing Cobeno from 20 yards out. However, his effort narrowly looped over the crossbar as the home team comfortably saw out the victory.
Barcelona are back in Liga action on Saturday where they will be hoping for another three points away against this season's surprise package, Levante. Rayo Vallecano visit local rivals Atletico Madrid the next day.