Juve moved up to fourth equal on points with third-placed AC Milan and two points ahead of Napoli who both play on Sunday.
The win ended the 20-match unbeaten run of Inter who had denied Juventus a 10th consecutive league title this season.
Cristiano Ronaldo missed a penalty after 24 minutes but turned in the rebound to bring his tally to a Serie A leading tally 29 goals this campaign.
But Inter got back level nine minutes later with a Romelu Lukaku penalty.
Juve pulled ahead before half-time when Cuadrado blasted in past Samir Handanovic.
Juve played most of the second half a man down after Rodrigo Bentancur was sent off for a second yellow car for a Lukaku tackle.
Captain Giorgio Chiellini turned into his own net with seven minutes to go but in a dramatic end to the game Juve were awarded a penalty for an Ivan Perisic foul on Cuadrado which the Colombian converted.
Inter also finished the game a man down with Marcelo Brozovic getting a second booking in injury time.
Earlier Atalanta sealed their spot in the Champions League for a third consecutive season with a 4-3 win over Genoa.
The Bergamo side are second, three points ahead of AC Milan and Juventus, and are assured of elite European football before the two teams go head-to-head next weekend.
Atalanta paved the way with three first half goals.
Ruslan Malinovskyi set up Duvan Zapata for the opener and then scored himself, with Robin Gosens grabbing a third before the break.
Mario Pasalic added a fourth six minutes after the break before 14th-placed Genoa hit back with an Eldor Shomurodov brace either side of a Goran Pandev goal just after an hour.
"For us, returning to the Champions League this year tastes better," said coach Gian Piero Gasperini, who brought the Bergamo side to elite European football for the first time in the 2019-2020 season.
"Three times in the Champions League is a great achievement. The trophy would be the icing on the cake, but we are convinced that we have won a lot anyway."
Atalanta will bid for just their second ever trophy in the Coppa Italia final against Juventus next Wednesday in Reggio Emilia.
The club won the Coppa Italia back in 1963.
Even if Milan, who host 16th-placed Cagliari on Sunday, win their last two matches, Atalanta are now assured of a top-four finish.