Paulo Dybala and Gianluigi Buffon were among several regulars left out of the starting XI and the Serie A champions paid the price as they conceded three second-half goals.
Gonzalo Higuain and Juan Cuadrado both failed to make the most of earlier chances to leave the door ajar for the home side.
Sampdoria needed no invitation to take advantage as Duvan Zapata crashed in a 52nd-minute header before Lucas Torreira fired home from outside the area to completely swing the momentum.
Gianmarco Ferrari appeared to have put the seal on an emphatic victory when he made it 3-0 with just over 10 minutes remaining, although the Bianconeri mounted a stoppage-time fightback as Higuain scored from the spot after Ivan Strinic was adjudged to have fouled substitute Douglas Costa.
Dybala had also come off the bench in a bid to rescue Allegri's side and the Argentina star fired in a quickfire second to set up a tense final few seconds, but the damage was done.
The defeat leaves Juve four points adrift of leaders Napoli and they could drop to third depending on Inter's result against Atalanta later on Sunday.
Higuain looked certain to open the scoring as early as the second minute when he latched on to Federico Bernadeschi's throughball, but a vital sliding challenge from Matias Silvestre did just enough to divert the shot wide.
Sampdoria were otherwise dealing comfortably with the visitors' occasional incursions, although they suffered a setback when Dennis Praet limped off following a heavy challenge from Stephan Lichtsteiner.
And the loss of the midfielder might have been compounded just beyond the half-hour had Cuadrado made the most of a one-on-one opportunity.
The winger was superbly sent through on goal by Higuain but, from a narrow angle, opted to shoot rather than pass and saw his powerful finish deflect almost inadvertently off Emiliano Viviano and around the far post.
Juventus' frustrations grew when their appeals for the VAR to adjudicate on a potential handball against Strinic were scuppered by the referee's half-time whistle.
Seven minutes later, they were trailing. Bernadeschi's wild attempted clearance from Fabio Quagliarella's cross hung in the air and Zapata rose above Lichtsteiner to head it beyond Wojciech Szczesny.
Allegri's side came close to falling further behind when Zapata race onto Quagliarella's reverse pass, but Szczesny was this time quick off his line to smother the chance.
Dybala was called from the bench shortly after the hour and almost had an immediate impact, the forward's close-range shot blocked amid a goalmouth scramble.
Juventus started to knock on the door with Viviano next required to tip the ball away from a stretching Sami Khedira, while Higuain's heavy pass ruined a promising counter-attack.
But, against the run of play, Sampdoria made their multiple reprieves count as Torreira speared an unstoppable strike into the bottom-left corner from outside the area after being set up by Gaston Ramirez.
Ferrari looked to have put a comprehensive seal on the three points when he turned in a close-range third from Quagliarella's clever pass in the 79th minute.
The Bianconeri did rally at the death to score twice in the closing moments – Higuain converting from the spot and Dybala clinically picking out the bottom corner after an assist by Costa.
Those strikes heightened the nerves of the home fans, but it came too late to prevent a first defeat in six league away games for Juve, as Samp strengthened their position in the top six.