David Villa and Koke scored either side of halftime to put Diego Simeone’s men in charge.
However, the visitors were thankful to Thibaut Courtois for the three points as the Belgian produced two stunning saves after Xabi Prieto had reduced Sociedad’s arrears 22 minutes from time.
On a night filled with goals, Sevilla and Malaga played out a 2-2 draw in the first Andalusian derby of the season.
Pedro Morales and Roque Santa Cruz twice put Malaga in front, but France international Kevin Gameiro leveled on both occasions with his first goals for Sevilla since joining from Paris Saint-Germain.
Also on Sunday, RCD Espanyol were held goalless at home by Real Betis Balompie.
Additional reporting by staff writer