Benzema scored two close-range finishes after cutbacks from Brazil wingers Vinicius Junior and Rodrygo.
Victory sees second-placed Real Madrid move within eight points of leaders Barcelona.
Carlo Ancelotti’s side got back to winning ways before Real’s Champions League semi-final against Manchester City on 9 May.
Only Lionel Messi (474), Cristiano Ronaldo (311) and Zarra (252) have scored more goals in the Spanish top flight than the 35-year-old former France forward.
Almeria pulled a goal back in the dying seconds of the first half, with Ramazani atoning after conceding the penalty by crossing into the six-yard box for Lazaro Vinicius to finish.
Two minutes after the restart, Rodrygo fired a screamer into the top corner from outside the box.
Substitute Lucas Robertone headed in from a Francisco Portillo cross just after the hour mark as relegation-threatened Almeria put up a fight against the defending champions, but were ultimately overpowered.
Eduardo Camavinga and Rodrygo had diving headers ruled out for offside with Los Blancos unable to get their fifth goal of the thrilling contest.