Juventus' Serie A title celebrations have been put on hold after a 2-1 defeat to Torino - the club's first derby loss in 20 years.
Victory at Stadio Olimpico coupled with Chievo beating Lazio would have wrapped up a fourth consecutive Scudetto for Juve, but the bragging rights were all Torino's on Sunday, though a draw in Rome keeps the league leader within touching distance of the trophy.
Giampiero Ventura's side went into the match on the back of 17 winless games against its neighbor and, although the club began the contest well, Andrea Pirlo's inch-perfect free kick 10 minutes before the break looked like continuing Juve's dominance.
But Matteo Darmian restored parity just before halftime as Juve's hopes of clinching a 31st Serie A title began to slip away.
Pirlo almost doubled his tally as he struck the woodwork with another delightful free kick early in the second half, but Torino made the most of that let off with Quagliarella - who left Juve at the beginning of the season - poking past Gianluigi Buffon.
Juve piled men forward towards the end and went desperately close to equalizing when Simone Padoin's cross hit the post, but Torino held on for its first derby win since April 1995's success by the same score line at Stadio delle Alpi.
Victory was richly deserved and the home side began full of attacking intent and went close twice inside the first eight minutes, as Marco Benassi hit off-target and Quagliarella forced Buffon into action, though Alessandro Matri ought to have put Juve ahead after bringing down a Pirlo pass on 12 minutes.
Torino was threatening on the break, with wing backs Bruno Peres and Darmian looking particularly lively.
But there was little the home side could do when Pirlo stepped up to a 35th-minute free kick and nonchalantly clipped his effort over the wall and in off the crossbar from 25 yards.
Torino's threat out wide remained, though, and the team went in at the break level thanks to Darmian prodding home from close range after darting onto Quagliarella's cut back.
Juve began the second half with something of an improvement and Pirlo almost scored a second free kick, curling a 30-yard effort on to the post.
Quagliarella made Juve rue that missed opportunity, converting at the near post from a teasing Darmian delivery.
Juve still had over half an hour to get back into the contest, but the chances looked to be running out when Padoin's cross hit the post and Simone Pepe was denied on the line by Daniele Padelli, who cemented hero status with a smart stop to deny Arturo Vidal.
The final whistle was met with jubilation as Torino clung on to a famous victory which also keeps the club firmly in the hunt for a European return next season.