Ronaldo sets new La Liga scoring record
The Portuguese former World Player of the Year bundled in at the far post after only four minutes at the Bernabeu, taking him past the previous best mark of 38 jointly held by Hugo Sanchez and Telmo Zarra.
Former Real striker Sanchez bagged his tally in the 1989/90 campaign and ex-Athletic Bilbao frontman Zarra in 1950/51.
Ronaldo ran from deep to fire a long-range shot low inside the far post in the 77th minute and had a hand in three more goals as his team mates Emmanuel Adebayor scored three, Karim Benzema two and Joselu one.
"This record is for the team and for the fans," the 26-year-old told Spanish television after the side's last game of the season.
"I'm generous with my colleagues because they are with me. This is a team game. I thank them for the 40 goals, which was the objective for everyone.
A run of 11 goals in Real's last four league games made it 53 scored in all competitions this season, including six in the Champions League and seven in the King's Cup, where he netted the winner in the final against Barcelona.
Ronaldo's second against Almeria took him past the 52 scored in all competitions this year by Barcelona's World Player of the Year Lionel Messi.
The Argentine has next weekend's Champions League Final against Manchester United still to play this season.