The prolific Portugal forward took his tally for the season to an unmatched 16 goals from 13 games in La Liga, adding to his top scorer status in the Champions League where he has eight from four games.
Karim Benzema and Sami Khedira added the others as Carlo Ancelotti's men climbed on to 31 points in third place, two behind city rivals Atletico Madrid, who visit promoted Villarreal on Sunday.
Unbeaten leaders Barcelona have 34 points and visit struggling Real Betis in Sunday's late game.
Ancelotti appears to have settled on a striking trio of Gareth Bale, Karim Benzema and Cristiano Ronaldo, a frontline dubbed 'The BBC' in the local media, and their devastating pace tore apart the Basque visitors in the first half.
Ronaldo had already struck the crossbar when he notched the opener in the 12th
A floated cross from Benzema found him unmarked at the back post, and the Portuguese forward netted from a tight angle.
Ronaldo returned the favour soon after, crossing low for the Frenchman to sidefoot home the second in the 18th, and then he won a penalty for the third, when Sociedad's Markel Bergara inadvertently handled the ball as he slid in for a tackle in the area.
The spot kick was converted, as for the fourth game in a row against Sociedad at the Bernabeu, Ronaldo netted a double, and he then laid on the team's fourth for Khedira in the 36th minute with a first-time pass.
French winger Antoine Griezmann pulled one back for the visitors with a neat lob in the 61st, but Ronaldo ended any thoughts of another defensive meltdown that has characterised Real's recent league games, with a fifth.
Ronaldo curled a freekick over the wall past a stationary Claudio Bravo in the 76th and then missed a sitter in the closing stages as he sidefooted wide with only the keeper to beat.
La Liga PHOTOS: Below-par Real hold on to beat Rayo
Brazil-born Costa gets Spain call-up for friendlies
Champions League: Bayern, Man City march into last 16
Ronaldo tricks, Bale scores first as Real Madrid crush Sevilla
Champions Bayern, Man City in Champions League last 16