Stefano Sensi scored the winner as Inter required extra-time to edge past Empoli 3-2 in the Coppa Italia last 16 on Wednesday.
Alexis Sanchez opened the scoring after just 12 minutes at the San Siro, but Empoli turned things around as substitute Nedim Bajrami equalised before the visitors fortuitously took the lead when Ionut Radu deflected into his own net.
Andrea Ranocchia produced an acrobatic stoppage-time equaliser to send the tie to extra-time and substitute Sensi delivered the decisive strike after 104 minutes.
Victory meant Simone Inzaghi's Serie A leaders squirmed through to the quarter-finals for the 18th time in 19 seasons.
@stefanosensi12 #CoppaItaliaFrecciarossa #InterEmpoli href="https://twitter.com/hashtag/FORZAINTER?src=hash&ref_src=twsrc%5Etfw">#FORZAINTER pic.twitter.com/NOPTUQ1Mjy Inter (@Inter_en) January 19, 2022
Inter deservedly took the lead when Sanchez nodded Denzel Dumfries' cross into the bottom-left corner - the forward's second goal in the competition, 4,291 days after his first for Udinese in 2010.
The same pair combined eight minutes later, but Dumfries saw his effort kept out by Jacopo Furlan before a fantastic double save from the Empoli goalkeeper denied Lautaro Martinez.
Ranocchia should have doubled the lead immediately after the interval but wastefully headed over.
Bajrami punished Ranocchia's miss as he placed a left-footed effort into the bottom-right corner after Kristjan Asllani's offload before VAR overturned a penalty decision for a Dumfries handball.
Empoli went ahead when Radu inadvertently turned into his own net after Patrick Cutrone nodded against the woodwork, though Ranocchia equalised with an audacious volley past Furlan.
Sanchez saw a tap-in ruled out for offside at the end of normal time, but Sensi blasted the winner into the top-left corner from the edge of the area in extra time.
What does it mean? Familiar story as Inter need extra-time
Inter enjoyed last-minute success against Juventus in the Supercoppa final last week and required more last-gasp heroics from Ranocchia to keep them in the tie.
The centre-back's equaliser meant four of the Nerazzurri's previous eight last-16 meetings in the competition have gone to extra-time.
Sensi's late strike ensured Inter remain unbeaten against Empoli in 11 games in this competition, the club's longest run against an opponent in the cup without losing, and Inzaghi's side will be among the early favourites to lift the trophy in May.
Bajrami almost single-handedly changed Empoli's fortunes after his half-time introduction, scoring the equaliser in a classy attacking display, but his efforts ultimately proved to be in vain.
The substitute created a game-leading four chances despite only playing the second half and extra-time.
Loanee Andrea Pinamonti was offered the unusual opportunity of starting up top against his parent club Inter but did little to impress.
The striker managed just 13 touches and won none of his five duels before his half-time removal in a timid performance.
Inter return to league action on Saturday at home to Venezia, while Empoli host Jose Mourinho's Roma the following day.