Alberto Bueno gave the hosts the lead on 37 minutes and Joaquin Larrivey extended the advantage 20 minutes later.
Fernando Soriano then gave Almeria a brief glimmer of hope with a powerful finish, but Larrivey struck again to secure another vital victory for Paco Jemez's side.
Rayo are guaranteed to be outside of the relegation zone by the end of the weekend whatever happens elsewhere in the league, while Almeria slumped to their third consecutive defeat and slip to 19th in the table.
Playing in an almost-full Vallecas, Rayo took the game to their opponents from the off.
Bueno had the first attempt on goal, beating two defenders in the box but slipping as he went to shoot, which made for a comfortable save for Esteban.
Larrivey then headed over the bar, unable to adjust his body enough to divert the ball towards goal, before Iago Falque came within inches of meeting a low cross across the box from Anaitz Arbilla.
But the hosts got the goal their pressure had warranted before half-time, Falque sending an out-swinging corner into the box and Bueno rising to head the ball into the bottom corner.
Falque had a chance to double the lead five minutes into the second half when he latched onto a pass from Roberto Trashorras in the box but was denied by Esteban.
Rayo sustained the pressure and got the second goal soon enough, Falque waltzing his way past an Almeria defender on the left wing and sending a low crossfield pass for Larrivey to tap in from inside the six-yard box.
Larrivey then headed over the bar and later shot wide of the post in a bid to kill the game off once and for all, but Almeria hit back on 71 minutes.
Soriano made a driving run towards Rayo's goal and slipped a pass towards Rodri, who pulled the ball back for the midfielder to smash into the net.
But Rayo were never really in danger of conceding a second, and Larrivey sealed the points with a similar goal to the one he had scored 20 minutes earlier.
This time he finished off a pass from Jonathan Viera from the left-hand side to score his fourth goal in three games, and his eighth for the season.