Spain winger Pedro netted in the 33rd, 47th and 72nd minute to put Barca in control and Cesc Fabregas added a fourth as Gerardo Martino's men made it five wins from five in La Liga.
Barca goalkeeper Valdes also played his part in the victory with a penalty save from Roberto Trashorras when the score was only 1-0.
"Rayo pressed us and they made it difficult to play short passes. We had the alternative to play long and at times you have to do this in these types of matches in order reach other parts of the field," said Barca coach Tata Martino.
"I really liked the team in the second half. We didn't have defensive errors and like the match against Ajax, we improved over the course of the match. We have the capacity to score a lot of goals."