Joseba Llorente Etxarri put the hosts ahead in the opening quarter of an hour, but an equaliser from Diego Forlan in the 72nd-minute catalysed Madrid's celebrated attack, and two goals in three minutes from Sergio Aguero put the Europa League champions into a seemingly unassailable two-goal lead.
Diego Rivas stoked Sociedad's faint hopes of a comeback with a stunning strike in the 86th-minute, but Simao Sabrosa made sure of all three points for the visitors with a penalty in the dying seconds of stoppage-time.
Madrid made a marginally stronger start to a tight first half, but Sociedad's mercurial 19-year-old winger Antoine Griezmann cracked the visiting defence wide open with just 12 minutes played.
The Frenchman swept an inch-perfect low cross in from the left wing, leaving Joseba Llorente Etxarri with the simplest of jobs to touch the ball past David de Gea, having stolen a yard on the lumbering Tomas Ujfalusi.
Sociedad almost doubled their lead five minutes later, but this time Llorente connected with the ball a fraction too late at the far post, and failed to turn the ball in with his desperate lunge.
Madrid were mostly restricted to wayward long-range efforts, but Sociedad's flamboyant Chilean goalkeeper Christian Bravo had to be at his very best to keep out Tiago Mendes on the stroke of half-time.
The Portuguese midfielder - on loan from Juventus - curled an exquisite drive from the edge of the area to the top right corner of the goal, and only a full-stretch, one-handed dive from Bravo prevented the ball from sneaking inside the far post.
Sociedad continued to look menacing after the break, but their stoic defence was finally undone by a breathtaking Madrid counter-attack in the 72nd-minute.
The hosts unsuccessfully appealed for a hand-ball against Tiago in the Atletico penalty area and, before they knew it, Aguero was haring up the right flank to gather a long ball over the top.
The Argentine selflessly squared the ball to Forlan, who slammed the ball past Bravo to level the scores.
Sociedad were visibly shaken, and saw Ion Ansotegi and Markel Bergara booked for rash challenges in the ensuing minutes as Madrid's attack suddenly found top gear.
Another fluent, flowing Madrid move put the visitors ahead in the 79th-minute, with Forlan finding Ujfalusi on the right wing before the big Czech defender made amends for his previous error with a perfect ball into the middle for Aguero to fire home.
Things went from bad to worse for a stunned Sociedad just three minutes later, as Aguero made it three with another breathtaking, sweeping move.
Forlan this time turned provider for Aguero, bringing down Tiago's long ball and touching it past the onrushing Bravo for Aguero to score into an empty net.
Rivas gave the hosts a glimmer of hope with a stunning left-foot strike in the 86th minute when his shot from the edge of the area went in off the flailing De Gea's left-hand post, but that hope was quickly extinguished in the dying moments when Mikel Gonzalez scythed down Jose Antonio Reyes to concede a penalty.
Simao stepped up to confidently and hammered the ball into the top left corner with the final kick of the game, condemning Sociedad to only their second home defeat this season and propelling Madrid to sixth in the La Liga table.
- Related links