Juventus 2 Torino 1: Pirlo secures dramatic derby win
The veteran playmaker lashed home a low shot from 25 yards with virtually the last kick of the game to cruelly deny Torino and extend Juventus' remarkable winning run at home in the league to 25 matches.
It looked as though the reigning champions and leaders would have to settle for a draw when Torino's Bruno Peres scored a superb individual goal midway through the first half, cancelling out Arturo Vidal's twice-taken penalty in the 15th minute.
The home side were even reduced to 10 men in the 78th minute when Stephan Lichtsteiner picked up a second yellow card, but Massimiliano Allegri's men were still able to find a winner right at the end.
Peres' goal was Torino's first against their fierce rivals since February 2002, and it looked as though they would be the first visiting side to come away from a league game at Juventus Stadium with anything since Cagliari in May 2013.
But Pirlo had the final word, a typically accurate finish leaving Jean-Francois Gillet with no chance and allowing the home fans to celebrate a seventh consecutive derby win.
Patrice Evra came in at left-back for the suspended Simone Padoin as one of two changes for Juve from their midweek UEFA Champions League win over Malmo.
The other saw goalkeeper Gianluigi Buffon miss out with a shoulder problem, replaced by Marco Storari who made his first appearance of the season.
Storari held an early free-kick from former Juve man Fabio Quagliarella, but the hosts were soon ahead through Vidal's penalty.
Pirlo's free-kick was handled by Omar El Kaddouri in the wall and, after placing his first effort into the top-right corner, Vidal sent his second into the bottom-left with cool precision.
The visitors were not behind for long, however, as Peres equalised with a goal of sheer brilliance.
The Brazilian picked the ball up on the edge of his own box and stormed down the right flank, beating Paul Pogba, Evra and Vidal for pace before thumping an angled finish across Storari and in off the left-hand upright.
Torino continued to pose a threat after the interval and a sliding Quagliarella diverted Amauri's low cross narrowly wide of the near post from close range in the 52nd minute.
Leonardo Bonucci tested Gillet with a low skidding drive from distance five minutes later and Juve were further frustrated 15 minutes from time when Vidal had a goal rightly ruled out for offside.
Their quest for a winner was made even harder three minutes later as Lichtsteiner was shown a second yellow card for a foul on El Kaddouri.
Yet Pirlo provided a sensational finale with seconds remaining, drilling a shot into the bottom-left corner following Vidal's lay-off.