Madrid needed a win, combined with an Atletico Madrid defeat, to keep their chances of leapfrogging their neighbours into second place alive, but they failed to gain a positive result on the road for the fifth straight league game since Zidane started his second spell as coach.
Brahim Diaz put Madrid ahead six minutes in at Anoeta, but Sociedad fought back through Mikel Merino before Jesus Vallejo received a red card for handball.
And though Willian Jose failed to convert the resulting penalty, Joseba Zaldua's header just before the hour and a first senior goal for Ander Barrenetxea earned Sociedad their second win over Madrid this term.
Diaz's first Madrid goal was a memorable one. Having exchanged passes with Karim Benzema, the former Manchester City man skipped past his marker and slotted a composed effort under Geronimo Rulli.
Madrid's lead was cancelled out 20 minutes later, though - Merino hammering home from the edge of the box moments after Mikel Oyarzabal had a goal ruled out for offside, with VAR upholding that decision after a lengthy check.
Matters were made worse for Madrid when Vallejo saw red for using a hand to deny Willian Jose a certain goal, but Sociedad's striker was unable to beat Thibaut Courtois from the spot.
Madrid's goalkeeper was at fault for Sociedad's second goal, however.
Having connected with Ruben Pardo's looping cross, Zaldua sent a header back across goal with Courtois wrong-footed, and Sociedad had the win wrapped up 10 minutes later.
After Oyarzabal rattled the woodwork, 17-year-old Barrenetxea reacted quickest to the loose ball, sending a powerful first-time finish under Courtois, with the crossbar preventing Adnan Januzaj adding further gloss.
What does it mean? Madrid's struggles on the road rumble on
Madrid had been in good form on the road prior to Zidane's return, but they have now failed to win all five LaLiga away fixtures under the Frenchman, losing three - the longest run Los Blancos have gone on without an away victory since April 2006.
Sociedad, meanwhile, have kept themselves in the hunt for a seventh-place finish.
Diaz takes his chance to impress
With Gareth Bale again left out, Diaz was given the opportunity to help lead Madrid's line, and his performance provided at least one positive for Zidane.
Proving his quality with that exceptional early goal, Diaz was an outlet all game, and almost turned provider with a wonderful pass that Benzema nearly latched onto.
Desperate Vallejo's panic proves costly
Vallejo reacted instinctively when he prevented Willian Jose's effort going over the line late in the first half, but his subsequent dismissal meant that Madrid were never likely to get back on the front foot, and Zidane may well have preferred his side go behind than to lose a man.