The 26-year-old opened the scoring in the 33rd minute when he knocked in a low cross from Lionel Messi, who was making his 250th La Liga appearance, and although Rayo enjoyed plenty of possession, the champions were clinical.
Pedro added two more similar goals in the second half, tapping in passes from Cesc Fabregas and Neymar, before former Arsenal man Fabregas added a fourth for good measure late on.
After its UEFA Champions League exploits against Ajax during the week, Barca made four changes.
Dani Alves, Andres Iniesta, Sergio Busquets and Alexis Sanchez all missed out, but coach Gerardo Martino had the luxury of being able to recall Martin Montoya, Xavi, Alex Song and Pedro.
The opening 10 minutes saw both sides create excellent chances, as Perea first headed straight at Victor Valdes, while Neymar had an effort blocked just in front of goal.
Barca, though, was clearly on top and eventually made the most of its domination just after the half-hour mark.
Messi, who had been relatively quiet to that point, played a pass into the area for Pedro and the wide man opened up his body and placed a shot into the bottom corner.
The visitors' hard work was nearly undone three minutes later when Adriano brought Roberto Trashorras down in the penalty area, but the former Barcelona youth player's spot kick was pushed away by Valdes.
Any threat of a Rayo upset was effectively extinguished just two minutes into the second half as Barcelona doubled the lead.
Fabregas exploited space between Tito and Arbilla down the left before squaring a ball into the danger area, which Pedro knocked into the roof of the net.
Rayo was afforded a fair share of possession, but Barcelona was the only side which looked like adding to the scoreline, as Messi found himself denied at the near post by goalkeeper Ruben.
And Martino's side put the result beyond doubt with 18 minutes remaining as Pedro completed his hat trick in the simplest fashion. Neymar flew past his marker and played a square pass for the Spain international to tap in.
But there was still time for things to get even better for the visitors, as Fabregas received a pass from Xavi on the edge of the area before curling a low shot into the bottom corner to seal the win.