Juve have spent almost the entire season lurching from one disaster to another but Adrien Rabiot's brilliant first-time finish five minutes after the break and a late deflected shot from youngster Nicolo Fagioli earned them a fourth straight league win.
Massimiliano Allegri's side, who were without Serbia striker Dusan Vlahovic and a raft of other players, are fifth in Italy's top flight and two points off Lazio – who they face next weekend – and Atalanta in the final two Champions League places.
"We've had some difficulties... there's desire and determination to do everything for your teammate and never give up," Rabiot told DAZN after netting his fifth goal of the season.
Inter are a point behind Juve in seventh after their fifth defeat of the season, which came after they wasted a clutch of opportunities.
Rabiot's opener came following superb play from the impressive Filip Kostic and five minutes after Hakan Calhanoglu had a piledriver tipped onto the bar by Wojciech Szczesny, one of a series of chances Inter had to take the lead before going behind.
Edin Dzeko headed wide from inches out in the 27th minute, but the worst miss came three minutes before halftime when Denzel Dumfries somehow skied a simple close-range chance from Nicolo Barella's cross-cum-shot.
And after Danilo had a goal for Juve ruled out for handball in the 65th minute, Martinez drove a poor low finish straight at Szczesny at the end of a quick counter-attack.
Fagioli then sealed the points with five minutes remaining after being fed by Kostic to give Juve hope their recent troubles might be coming to an end.
"We played really well in the first half and you can't go in at halftime goal-less there," said Inter coach Simone Inzaghi.
"It's a hard defeat in a big match against a rival, and it hurts."