Inter found themselves a goal and a man down inside 20 minutes after Douglas Costa’s opener and a red card for Matias Vecino, but they fought back to lead through Mauro Icardi and an Andrea Barzagli own goal.
But with the destiny of the title set to slip into Napoli’s hands if Juve failed to win, Milan Skriniar deflected a Juan Cuadrado shot into his own net and Gonzalo Higuain headed home a dramatic 89th-minute winner.
Juve lead Napoli, who visit Fiorentina on Sunday, by four points with three games remaining.
Download our app and read this and other great stories on the move. Available for Android and iOS.