Juve had won their last four Serie A games while Sampdoria had lost 10 in 13 and only one outcome looked possible when Sebastian Giovinco put the hosts ahead with a 24th-minute penalty and Sampdoria had Gaetano Berardi dismissed seven minutes later.
But Icardi netted twice in the second half as Sampdoria hit back to hand the champions their third league defeat of the season.
Uruguay forward Cavani's hat-trick made him Serie A top-scorer with 16 goals and lifted Napoli into third place as they overtook Fiorentina and Inter Milan. Roma are the league's leading scorers but have the third worst defence.
Fiorentina suffered their first home defeat of the season, losing 2-0 to relegation-threatened Pescara, and fourth-placed Inter Milan continued their slump as they were beaten 3-0 at Udinese.
Goalkeeper Mattia Perin was the hero for Pescara, saving everything Fiorentina threw at him before Jonathas and Mervain Celik snatched the points by scoring from the visitors' only two real chances in the second half.
Inter dominated the first hour at Udinese and missed a flurry of chances including one incredible effort from Brazilian Jonathan who contrived to fire wide from six metres in the 54th minute with the goal at his mercy.
They paid the price when 35-year-old striker Antonio Di Natale scored twice and Colombian Luis Muriel was also on target in the last half-hour.
Inter's unhappy afternoon was complete when defender Juan Jesus sent off for a second bookable offence.
Juventus, with 44 points from 19 games, still reached the halfway mark in the championship with a five-point lead over Lazio who beat Cagliari 2-1 on Saturday.
Napoli have 37 points with Fiorentina and Inter on 35.
In other matches, two goals by Marco Boriello gave Genoa a 2-0 win over Bologna which lifted them out of the relegation zone and Bojan Krkic and Giampaolo Pazzini scored to give seventh-placed AC Milan a 2-1 home win over bottom club Siena.
Chievo Verona beat Atalanta 1-0 in a mid-table clash and a stoppage-time goal from Amauri gave Parma a 2-1 win over Palermo which left the Sicilians one place off the bottom with 15 points, one below Cagliari and two adrift of 17th-placed Genoa.
Igor Budan had put Palermo level in the 85th minute, wiping out Ishak Belfodil's opening goal.
Juventus had won 14 of their first 18 games and took the lead when Giovinco converted a penalty awarded after Claudio Marchisio was fouled in the 24th minute.
Berardi was then shown a second yellow card as Sampdoria's problems multiplied.
But Sampdoria levelled seven minutes after the restart when Juventus goalkeeper Gianluigi Buffon misjudged Icardi's awkwardly bouncing shot.
In the 68th minute, the 19-year-old got to the byline and fired into the roof of the net from an almost
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.