Kalidou Koulibaly, Hirving Lozano, Matteo Politano and Eljif Elmas struck for the Naples hosts before half-time.
But the dynamic Serie A newcomers kept the game alive through goals from Emmanuel Gyasi and Gennaro Acampora.
Spezia won 2-1 in Naples earlier this month in league action.
The Neapolitans are to meet Atalanta in the first-leg of the semi-finals next week as the Bergamo side eliminated Lazio 3-2 on Wednesday.
Juventus beat second-division SPAL 4-0 and will meet Inter Milan, who edged AC Milan 2-1 on Tuesday.(dpa/NAN)
Read Also: Champions Liverpool return to EPL top four after whacking Tottenham