Struggling Athletic took the lead in the Basque derby on the half-hour mark through Ibai Gomez but La Liga high-flyers Sociedad drew level almost immediately thanks to Antoine Griezmann.
The visitors then netted twice in 10 second-half minutes through Imanol Agirretxe and Carlos Vela to claim the victory which saw them move level with fifth-placed Valencia on 40 points and also end the club's miserable run of results in their neighbours' back yard.
Sociedad had picked up just one point in visits to San Mames since their last success in 2001, and for a while that poor sequence looked set to continue as Athletic started in impressive fashion.
The home side, who came into the match 11 points and eight places below Sociedad in the standings, had already gone close on a number of occasions - including seeing visiting goalkeeper Claudio Bravo brilliantly save from Mikel San Jose's header - when they went ahead through Gomez.
Jon Aurtenetxe sent over a deep cross from the left and Gomez got on the end of it to fire home an unstoppable volley into the roof of the net to send the home fans wild.
Marcelo Bielsa's men enjoyed their lead for just four minutes, though, before Sociedad drew level when Griezmann nodded home Gonzalo Castro's cross at the far post.
Both sides had chances to get their noses in front before Sociedad made it 2-1 thanks to a bad mistake from home goalkeeper Real Fernandez-Cavada midway through the second half.
The 24-year-old failed to gather an inswinging Castro free-kick and Agirretxe took advantage to bundle the ball home from point-blank range.
That was in the 66th minute and 10 minutes later Sociedad all but finished off their opponents when substitute Vela, not long after being sent on from Agirretxe, clinically slotted just inside the far post from the edge of the box to make it 3-1.
Athletic pushed hard in the closing stages to try and get a foothold back in the match but they could find no way through as they slumped to a demoralising loss which leaves them six points above the relegation zone.