Medina the difference in Madrid derby
Rayo's Guinean forward Alhassane Bangoura dribbled between two defenders to open the scoring in the 14th minute.
Getafe goalkeeper Miguel Angel Moya was peppered with three shots on target which he athletically punched away in the 24th minute - only for Rayo captain Piti to latch onto a long cross from Javier Fuego and score four minutes later. Piti then netted his eighth goal of the season in the 52nd.
Substitute Francisco Alcacer pulled one back for Getafe in the 65th minute.
Rayo, with 28 points, rises to seventh place in the standings which are led by Barcelona on 52.