The centre-back struck on 78 minutes to put the Madrid side ahead, only 15 minutes after centre-back Saul Niguez had been sent off for two bookings.
Paco Jemez's side move well clear of the relegation zone and up to 13th thanks to the result, their second successive win, while Almeria stay stuck to the bottom of the Primera Division and still without a victory all season with nine games now played.
The fixture pitted together the two worst defences in the league, with the teams conceding a total of 40 goals before kick-off.
Although the match remained goalless for so long, there was no shortage of chances and both goalkeepers, particularly Almeria's Esteban, were kept busy.
Roberto Trashorras tested the home goalkeeper early on with an effort from the edge of the area but Liverpool loanee Suso then had a better chance for the hosts, bursting through on goal on the counterattack only to be thwarted by Rayo stopper Ruben.
Jonathan Viera, the scorer of Rayo's last-minute penalty that gave them victory over Real Sociedad last weekend, had two attempts in quick succession - the first a shot that Esteban had to tip away for a corner and the second a powerful but high effort that went well over the bar.
Striker Rodri was presented with a chance to give the hosts the lead just after the half-hour mark, evading his marker to get his head on to a cross from Suso from a free-kick, but Ruben was able to tip the ball over the bar.
Almeria midfielder Verza then had a go from outside the area but saw his shot deflected wide for a corner.
Rayo forward Iago Falque came the closest to giving his side the lead, shooting towards the bottom left corner, but Esteban was able to get a hand to the effort and tip the ball on to the post.
The visitors' hopes of winning the game took a blow shortly after the hour mark when Saul was sent off for his second yellow card in 10 minutes, the second a shove on Suso.
The young Atletico loanee did not take the decision lightly and took his time leaving the pitch, with his own team-mates having to prevent him from confronting a few Almeria players.
The only goal of the game came with 12 minutes left when Galvez stepped up to take a free-kick just to the right of the penalty area. The defender curled the ball right into the top corner to give the visitors the lead they had deserved on balance, but at a a time when it was looking less and less likely they would go in front.
Despite needing an equaliser and with an extra man advantage, Javier Francisco Rodriguez's side were unable to further trouble Ruben in what remained of the match, and the young novice coach's job could well be on the line after his side were defeated by their fellow strugglers.