The champions raced into an early lead with youth-team striker Alvaro Morata stroking home three minutes into his first league start for the club, and Ramos powered in a header from a freekick in the 12th.
However, Real's captain Ramos, 26, then picked up two yellow cards in a minute, the second for handball, and he was sent off for the 17th time in his professional career.
Rayo battled hard but the hosts held firm showing little sign of tiredness after their midweek Champions League draw with Manchester United.
Third-placed Real moved on to 49 points from 24 games, four behind second-placed Atletico Madrid, who were 3-0 victors at Real Valladolid.
Barcelona are top with 65 points after a 2-1 comeback win at Granada on Saturday, when Lionel Messi scored both goals.
- Sports & Recreation