The visitors broke the deadlock against the run of play right on the stroke of half time, taking an undeserved lead into the interval courtesy of Asier Illarramendi's close-range finish against his former club.
Here, Sports Mole takes an in-depth look at a big win for Madrid.
On target: 4
On target: 7
Was the result fair?
Yes. The final scoreline is perhaps a little harsh on Sociedad as the two late goals gave a gloss to the result, but Madrid deserved the three points for their second=half performance. Sociedad were the better team in the first half, looking sharper than their opponents and playing positive football.
However, the second half was a different story as Madrid began to dominate, scoring three goals and hitting the woodwork on two other occasions. Sociedad will have felt hard done by at half time, but they can have no complaints at ending the 90 minutes on the losing side.
The hosts looked very bright in the first half, more than matching Madrid all over the pitch. They comfortably dealt with any attacks from the visitors and regularly looked capable of creating chances at the other end. However, the reality is that they only came close to scoring once in the first half as they failed to turn their good performance into chances.
They were simply outplayed in the second half as Madrid moved up a gear and began to control the game. They had their moments early in the half, but as soon as Bale scored Madrid's second, it looked like being game over for the hosts.
Their hopes of qualifying for the Champions League next season now hang by a thread as they wait anxiously to see how Athletic Bilbao do on Monday night. Defeat for their Basque rivals will hand them a lifeline, but a win would see the gap grow to a nigh-on insurmountable nine points.
Real Madrid's performance
There is no doubting that they were lucky to go into the break ahead after a lacklustre performance in the opening 45 minutes. Sociedad seemed first to every ball and were comfortably the better side before Benzema's shot was parried by Claudio Bravo straight to Illarramendi, who finished from close range.
Those were Madrid's first two shots on target in the half, but they had no such trouble breaking Sociedad down after the break. They looked more like themselves in the second half and, although they needed a mistake from Bravo to hand them their second goal, they deserved to extend their lead.
With the closest La Liga title race in years shaping up, this was a crucial victory for Madrid to stay within touching distance of the top two. Coach Carlo Ancelotti would not have minded a narrow 1-0 win before the game, but to recover from a poor first half with a fine second-half display, particularly without Cristiano Ronaldo, will please him.
They have played better this season, but 4-0 win away to Sociedad is a very impressive result and a message will have well and truly been sent to Atletico Madrid and Barcelona. Real are not giving this one up without a fight.
Sports Mole's man of the match
Daniel Carvajal: It may seem a strange choice considering Madrid's four goals, but Daniel Carvajal was a constant threat down the right flank and was also solid defensively throughout.
He created a number of chances with his marauding runs forward from right-back, particularly in the second half, while he also did a good job nullifying the dangerous Carlos Vela and Antoine Griezmann when called upon.
This one has to go to Claudio Bravo for his part in the second goal. Usually such a good distributor of the ball, Bravo's kick this time went straight to Gareth Bale, who fired it into the bottom corner from distance as the keeper failed to recover in time.
Nothing should be taken away from Bale as he still had a lot to do, but Bravo gifted him the chance to make something out of it. That second goal proved to be the killer blow for the hosts, who never really recovered from it.
Alejandro Hernandez had a quiet match tonight with not many major decisions to make. There was the slightest claim for a handball against Xabi Alonso in the first half, but the referee paid it no attention and was right to do so.
His officials did make a couple of mistakes in the first half, flagging for offside when the players were, in fact, onside, but they didn't prove to be costly errors.
Sociedad: Sociedad will face Celta Vigo away from home next Saturday.
Real Madrid: Madrid, meanwhile, will look to complete their progress into the semi-finals of the Champions League as they take on Borussia Dortmund in the second leg with a 3-0 aggregate lead.