Juventus scored two late goals to come back from a 2-1 deficit and get a much-needed 3-2 win over 10-man Inter Milan.
Juventus remain on course for a seventh successive Scudetto, after plundering two late goals against an Inter side who played most of the match with ten men.
Douglas Costa's first-half opener was cancelled out by Mauro Icardi's header and an own goal, but Inter conceded a late own goal and a Gonzalo Higuain winner in a marvellously entertaining and typically fractious Derby d'Italia - though the match only really caught fire in the second half.
After last weekend's dismal home defeat against Napoli, Juve urgently needed a win over their bitter Milanese rivals to deny the Neapolitan side the chance to leapfrog them against Fiorentina on Sunday.
Meanwhile, Luciano Spalletti's side were hoping for a win to keep their hopes of Champions League qualification alive. They would have been encouraged by back-to-back victories in their two previous Serie A matches, leaving them just one point behind 4th-placed Lazio.
Juve manager Massimiliano Allegri made no fewer than five changes to the side who played so poorly against Napoli, changing his entire back four and relegating Paulo Dybala to the bench. Only one of those defensive changes was enforced, as Giorgio Chiellini had not fully recovered from an injury.
Neither side made an ideal start, with Inter's Antonio Candreva giving away a needless corner, while Juve's Juan Cuadrado - a surprise choice at right wing-back - was booked for a rash challenge on Ivan Perisic.
Those were the only incidents of note in a cagey opening period, as the significance of the match seemed to inhibit both sides' creativity and attacking instincts.
Then, in the 13th minute, Juve's Douglas Costa capitalised on some criminally lax defending by the home side, emphatically drilling home a fine shot from Cuadrado's high, floated cross which really ought to have been cleared. Once the referee had consulted the VAR to ensure there were no infringements in the buildup, the goal was given.
Things went from bad to worse for Inter, as they went down to ten men in the 18th minute - again, after the VAR had confirmed that Matias Vecino's hideous challenge on Mario Mandzukic was worthy of a red card. The only small mercy for the hapless Nerazzurri was that the resulting free kick came to nothing.
From that point on, the Bianconeri looked comfortable for most of the first half, though Candreva tested Gianluigi Buffon with a searing long-range drive in the 29th minute,
The atmosphere was considerably more electric than the football, and at times a second red card looked likelier than a second goal, such as when Mandzukic and Candreva angrily clashed in the 38th minute after the Italian had clipped the Croatian.
Just as half time approached, Inter had a reprieve, as Blaise Matuidi was rightly deemed by the VAR to be offside after finding the net from close range. A second Juve goal would surely have killed off the home side, who offered little threat going forward and looked uncharacteristically brittle in defence on several occasions.
Something had to change for Inter at half time - and it did. And how.
Juventus started the second half in extremely lethargic fashion, and Inter were level in the 52nd minute. The away side's defending left a lot to be desired, as Mauro Icardi was left unmarked to head past Buffon from a free kick which Mandzukic had needlessly conceded.
Juve offered little in reply, until Gonzalo Higuain missed a golden opportunity to restore their lead in the 63rd minute, firing wide after rounding Inter keeper Samir Handanovic.
Before then, the away side were fortunate not to earn a red card of their own, as Miralem Pjanic appeared to make contact with Rafinha's face. In any case, they deservedly went behind in the 65th minute.
Cuadrado was at fault, being too easily bamboozled by Perisic, who drove in a low cross which the unfortunate Andrea Barzagli could only turn into his own net.
Juve did their utmost to turn the tide, and Handanovic had to make a smart low save against Costa and a brilliant stop from substitute Paulo Dybala's fine free kick. However, Inter could have killed off the game in the 76th minute, when Icardi narrowly failed to convert the tireless Candreva's excellent low cross after Juve had been caught on the break.
Then, just as Inter seemed to be cruising to victory, Juventus delivered a stunning late 'smash and grab' raid.
First, Cuadrado fired a cross-cum-shot across goal which was cruelly deflected into his own net by Milan Skriniar in the 87th minute.
Two minutes later, with the home side still reeling, Higuain headed home Dybala's free kick to earn Juve a win that their second-half performance didn't deserve.
Juventus will now hope that Napoli slip up away to Fiorentina on Sunday to leave them in pole position in Serie A, while Inter will hope that Torino can do them a favour against Lazio to keep their top-four hopes alive.