A double from Imanol Agirretxe saw the Phillipe Montanier's side on its way to a sensational win over Los Che in a six-goal thriller at the Anoeta.
Roberto Soldado had given Ernesto Valverde's men the lead in the first half, but a terrific volley from Inigo Martinez, a neat finish from Chori Castro, and a double from Imanol Agirretxe saw the home side walk out with all three points, despite receiving a late fright from Jonas.
Carlos Vela almost gave his side the perfect start after just two minutes. The home side hit the counterattack at pace down the left and the ball eventually came to the Mexican on the right side, but his whipped strike towards the far corner went just the wrong side of the post.
Valencia responded with a decent chance of its own four minutes later. Jeremy Mathieu curled an accurate 25-yard free kick over the wall which looked destined to nestle in the corner, but goalkeeper Claudio Bravo managed to get across to beat the set piece away from danger.
Both sides looked more than capable of opening the scoring, but it was the visiting team which struck the first blow 25 minutes in. Aly Cissokho skipped past a couple of challenges down the left flank and got to the bye line before curling a superb cross to the front post, and the predatory Soldado got in front of his marker to glance a header into the bottom corner.
Things could have been so much worse for Sociedad four minutes later when Bravo rushed off his line and appeared to touch the ball with his hand outside the box. But the goalkeeper was saved from a potential red card when the referee waved play on, having missed the call.
The home side looked buoyed from the slice of luck and got back on level terms 10 minutes before the end of the first half. A quick corner kick saw Castro pick up the ball on the left flank and float a cross to the back post for Martinez. The 21-year-old shook off the attention of Ricardo Costa and wonderfully side-footed the ball on the volley into the top right corner.
In the second half it was Valencia which benefited from the lenience of referee Fernandez Borbalan. A cross came in from the right side and Cissokho appeared to bat the ball away with both hands inside the area, but the official inexplicably failed to award Sociedad the penalty.
The Basque side was not down, though, and edged ahead with 18 minutes remaining through a sublime counterattack.
An Ever Banega free kick was cleared out of the box, and Agirretxe burst out of his own half before exchanging a scintillating one-two with Castro. The 26-year-old then galloped down the right wing before sliding a perfect pass back to the Uruguayan, who slotted in past the static Diego Alves.
The match looked to have been put to bed five minutes from time when Xabi Prieto clipped a lovely cross to the back post for Agirretxe who made no mistake and smashed a volley past Alves in the Valencia goal. However, Jonas pounced on a mistake from Bravo to head home from close range to make it 3-2, setting up a scintillating climax.
It was to be Sociedad's night though, and the club made it 4-2 in the last minute when Agirretxe ran through on goal and wonderfully chipped Alves, sending the Anoeta faithful into raptures. Sociedad now moves five points clear of Malaga and Valencia in fifth and sixth place in the league respectively, with the prospect of Champions League football looking more likely as the weeks progress.