The Nerazzurri seemed to have guaranteed themselves a safe passage to the next round after a three-goal lead at the interval, but the Serie B visitors gave them a scare
The Nerrazzurri were 3-0 up by the break, but nearly threw away that advantage against the Sicilians, who scored twice in the second half but ultimately ran out of time to complete the comeback.
Richard Marcone’s own goal sent the hosts into the lead after four minutes, with the defender turning into his own net from Fredy Guarin’s free kick that ricocheted off the post.
Ishak Belfodil added a second for Inter with a neat volley, before Saphir Taider made it three with a penalty on the stroke of half-time.
Trapani were a different side after the restart though, and gave themselves a glimmer of hope when Andrea Ranocchia’s mistake allowed Cristian Caccetta to slide home shortly before the hour mark.
And after a second half of concerted pressure, Giuseppe Madonia set up a grandstand finish by beating Juan Pablo Carrizo in the final minute of normal time.
The fightback was nearly completed at the death, but Maurizio Ciaramitaro was unable to profit from a Carrizo error, allowing Inter to hold on to face Udinese on January 14.
Walter Mazzarri was clearly unhappy with the home side’s lack of focus in the second half that nearly allowed the visitors back into the game.
“Such carelessness should not happen. At half-time, I told the team to handle the situation, but when you lose attention, that's what happens,” he lamented to La Gazzetta dello Sport.
“I wanted to make the boys begin to grow as a group, and this seemed like the right time, but you can’t underestimate anything. In the first half, we were focused and did well, then we dropped. These are the points on which to work."
Belfodil’s goal appeared to do little to convince Mazzarri of giving him a more regular place in the first team, as the 52-year-old appeared willing to let the summer signing from Parma leave San Siro on a temporary basis.
Mazzarri added: “He [Belfodil] will decide what he wants to do in January, but he will listen to the feedback of the club."
Inter sit in fourth place in Serie A, 10 points behind leaders Juventus, but only three behind Napoli in the third and final Champions League place.