Karim Benzema’s hat-trick for Real Madrid against Almeria saw him pass Hugo Sanchez as the fourth-highest goalscorer in La Liga history with 236.
Benzema scored two close-range finishes after cutbacks from Brazil wingers Vinicius Junior and Rodrygo.
Lucas Vazquez was fouled by Largie Ramazani and Benzema converted from the spot to complete his first-half treble.
Second-placed Real Madrid later saw Barcelona restore their 11-point lead at the top, beating Real Betis 4-0.
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.