Carlo Ancelotti's men fired four past Sociedad to stay within touching distance of league leaders Atletico Madrid
With title rivals Atletico Madrid and Barcelona both winning earlier on Saturday, Carlo Ancelotti's men came into the game under pressure to respond, and they did just that by grinding out an important victory.
In a largely disjointed first half, they were grateful to ex-Sociedad man Asier Illarramendi - in the side in place of the rested Cristiano Ronaldo - who tapped home from close range at the end of the first period after Sociedad goalkeeper Claudio Bravo had saved an initial effort from Karim Benzema.
The midfielder chose not to celebrate the goal against his former employers, although it came as a much-needed boost for Ancelotti's side heading into the break.
Madrid were much improved in the second period and midway through the half Gareth Bale took advantage of Bravo's poor kick to smash a low finish into the bottom left-hand corner from 30 yard.
In the final stages, Pepe added a third before substitutes Angel Di Maria and Alvaro Morata combined, the latter slotting home to seal the victory.
The result leaves them two points behind Barca and three adrift of leaders Atletico with six matches to go while the loss puts a severe dent in the hosts European ambitions.
The two sides immediately above them, Sevilla and Athletic Bilbao, play on Sunday and Monday respectively, with Sociedad level on points with Sevilla but still six adrift of Bilbao in the final Champions League qualifying spot.
The visitors survived a scare in the 16th minute when Diego Lopez brilliantly denied Carlos Vela's close-range effort, although the strike would not have counted anyway as the as the assistant referee had - incorrectly - ruled the Mexican to be in an offside position.
Six minutes later, Vela was involved again, this time sending in an inviting cross from the left that Antoine Griezmann glanced just over the crossbar.
Illarramendi gave Madrid a lead they scarcely deserved on the stroke of half-time, reacting quickest to tap in the rebound after Bravo had parried Benzema's fiercely-struck shot.
The advantage was almost doubled within four minutes of the restart, Sergio Ramos thumping a header against the crossbar after meeting Xabi Alonso's free-kick from the right.
Alonso posed a threat from another set-piece eight minutes later, curling in a 25-yard free-kick that Bravo was equal to low to his left.
The visitors were denied by the woodwork again in the 65th minute, Benzema rattling the frame of the goal with a rasping left-footed shot that left Bravo helpless.
A minute later, Bale put the result beyond doubt, firing home after Bravo's mis-cued kick out of his hands fell perfectly at the Welshman's feet before Madrid killed the game and added gloss to the scoreline late on.
Five minutes from time, Pepe turned home Ramos' headed knockdown from a corner before Morata added the fourth with two minutes left, as Madrid extended their unbeaten run against their opponents to 14 matches.