Despite resting Andrea Pirlo and Leonardo Bonucci ahead of Tuesday's Coppa Italia quarter-final against Roma, Juve were 3-1 up at the break and seemingly cruising.
But Sampdoria rallied in the second half, cutting the deficit to 3-2 before Paul Pogba scored a spectacular late goal to secure the three points for the champions.
Arturo Vidal gave the leaders an 18th-minute lead in the Turin rain after latching on to a Pogba pass to beat Junior Da Costa in the Sampdoria goal.
Fernando Llorente quickly made it 2-0 with a powerful downward header before Carlos Tevez rattled the post with a thunderous drive.
Sampdoria, who lost to Juve on the opening day of the season, pulled a goal back on 38 minutes when Andrea Barzagli, back from suspension, put through his own goal as he tried to cut out a dangerous cross from Manolo Gabbiadini.
To their credit, Sampdoria hit back again when Gabbiadini beat Gianluigi Buffon from close range in the 69th minute before the same player saw a fierce drive come back off the Juve crossbar.
But the impressive Pogba unleashed a 20-metre screamer in the 78th minute to seal the win.
Roma send Livorno back to bottom
Earlier, first-half goals from Mattia Destro and Kevin Strootman, and a late strike from Adem Ljajic secured a 3-0 win for Roma that sent Livorno back to the bottom of Serie A.
Livorno, who won promotion from Serie B last season, responded to their struggles in the first half of the campaign by sacking coach Davide Nicola last Monday after the side had taken just a point in their last eight games.
Successor Attilo Perotti, however, failed to come up with a magic formula at the Olympic Stadium, where Roma coach Rudi Garcia felt confident enough of a win to rest a host of regulars.
Striker Francesco Totti, defender Douglas Maicon and midfielder Radja Nainggolan all started on the bench but it took only six minutes for Roma to pull ahead, Destro pouncing on a backheel flick from Gervinho to beat Francesco Bardi in the visitors' net.
Roma piled on the pressure and when Ljajic and Daniele De Rossi combined, Bardi, celebrating his 22nd birthday, pulled off a great save from point-blank range.
It was only a matter of time before the Livorno net bulged again and although Destro came close, it was Strootman who had the pleasure after he picked up the rebound from the striker's chip Nahuel Valentini prevented it from going in.
Gervinho came close again but saw his close-range header from Vasilis Torosidis's cross go wide while a Destro strike just before half-time was ruled offside.
Roma continued to pile on the pressure in the second half but it took until the 78th minute for Ljajic to add his name to the scoresheet after collecting a pass from Nainggolan.