The champions extended their unbeaten league run to 13 matches, but Cristian Chivu's side were forced to fight for the three points after a stunning opening from the visitors.
Udinese silenced the home crowd after just 16 minutes by taking a 2-0 lead.
James Abankwah opened the scoring when he headed home an excellent delivery from Unai Gomez for his first goal for the club.
Inter almost responded immediately, but Maduka Okoye made a superb double save to keep out Marcus Thuram.
Udinese then doubled their advantage when Keinan Davis created the opening for Jurgen Ekkelenkamp, who finished from close range.
Inter needed inspiration and found it through Carlos Augusto.
The defender produced a stunning long-range strike in the 26th minute, firing into the bottom corner to bring the hosts back into the contest.
The comeback gathered pace before half-time when Nicolo Barella finished from inside the box to make it 2-2.
Inter continued to push after the break and finally moved in front in the 58th minute.
Andy Diouf released Thuram on the counter-attack and the France international kept his composure to slot the ball into the bottom corner from 12 yards.
Udinese were now under heavy pressure and Inter added a fourth goal midway through the second half.
Piotr Zielinski created the chance for Pio Esposito, who calmly finished from close range to score his second league goal of the season.
Inter then put the result beyond doubt with just over 10 minutes remaining.
Substitute Ange-Yoan Bonny saw his first effort saved by Okoye but reacted quickly to fire home the rebound and make it 5-2.
Idrissa Gueye pulled one back for Udinese in stoppage time, but there was no way back for the visitors as Inter completed a remarkable comeback.
The victory moved Inter into second place, behind early leaders Roma, setting up an intriguing meeting between the two sides on Saturday.
Udinese remain 13th with four points from their opening four matches and will look to respond when they host Cagliari this weekend.