The Wales star made his first appearance in La Liga since returning from a hip injury to help the La Liga leaders record yet another win
The winger grabbed his first goal in five Madrid games on nine minutes and although Sergio Ramos doubled the lead just before the break, former Real youngster Alberto Bueno scored to ensure Rayo were just one behind at half-time.
The two-goal cushion was soon restored, though, as Toni Kroos found the net in style in the 55th minute and their fourth was not far behind.
Karim Benzema, although appearing to be offside, knocked in from close range with 31 minutes to go as Cristiano Ronaldo picked up his second assist of the day.
Ronaldo finally grabbed a goal of his own late on, with the help of some questionable goalkeeping, with victory seeing Real remain top of the Liga table with 27 points, two more than rivals Barcelona.
Ancelotti risked upsetting supporters by not including the in-form Isco in his starting line-up as Bale made his return from a gluteal injury.
But the Italian's decision was vindicated just nine minutes in, with Bale getting on the end of Kroos' teasing delivery to give Real an early lead.
The hosts struggled to build on that early goal, though, and they had Keylor Navas - in for Iker Casillas - to thank for keeping them ahead in the 21st minute as he palmed away Leo Baptistao's stinging drive.
Rayo's resurgence almost fell apart a few moments later, but Mohammed Fatau escaped punishment despite seemingly bringing Ronaldo down when through on goal.
Atletico Madrid-owned Baptistao continued to cause problems at the other end and he went close again 31 minutes in, glancing a header just wide of the bottom-left corner.
But Real eventually doubled their lead in the 40th minute as James Rodriguez's corner was flicked on by Pepe and Ramos - attempting a volley - diverted the ball home with his thigh.
Rayo did hit back with a goal of their own shortly after, though, as Baptistao pounced on Rodriguez's dreadful back-pass before squaring to Bueno for an easy finish.
Real reopened the two-goal deficit nine minutes into the second half and they did so in impressive fashion.
Ronaldo poked a pass back out to the lurking Kroos 25 yards from goal and the German produced a fine finish which oozed class, delicately placing his first-time effort into the bottom-right corner.
Ronaldo was at the centre of things again four minutes later as he flashed the ball into the danger zone and Benzema was on hand to tap in, despite appearing beyond the last defender.
Goalkeeper Cristian Alvarez tipped Bale's fierce volley on to the crossbar, but he gifted Real a fifth moments later, allowing a tame Ronaldo effort to squeeze between his legs to give the scoreline a healthy gloss.