Federico Macheda scored his first Sampdoria goal when held 2-2 in extra time by Udinese, but they only scraped through on sudden death penalties.
Macheda had his first start in a Samp jersey and was keen to make his mark. Giampaolo Pazzini got in front of his defender to turn a header just wide in the opening five minutes.
Macheda then had a fine chance when he burst through the Udinese defence to sting Emanuele Belardi's palms at the near post.
The former Manchester United starlet got his first goal for the Blucerchiati soon after.
He ran on to Pazzini's through ball, dribbled past Andrea Coda and flicked a left-foot cross-shot that looped over the goalkeeper into the far top corner of the net.
Udinese thought they had equalised within 60 seconds, but Antonio Di Natale was flagged offside as he slipped it past Junior Da Costa.
Just before the break, the Friulani lost Gabriele Angella to a knee injury, but they also went very close to an equaliser when Da Costa flew to fingertip a Di Natale free kick out from under the bar.
Pazzini pounced on a defensive error from Cristian Zapata to run on goal, but Giovanni Pasquale did just enough to put him off, as the striker fired over the bar.
On 64 minutes Massimo Volta brought down Alexis Sanchez inches outside the area, while Juan Cuadrado flashed a snapshot off target.
Substitute Sanchez was single-handedly sparking a reaction in Udinese and forcing a series of bookings for his Sampdoria opponents.
Belardi spilled an Angelo Palombo free kick, but there was nobody ready to tap in the rebound.
Pazzini also thought he'd sealed it on the counter when he sprung the offside trap on an Andrea Poli slide-rule pass, but flashed the angled drive across the face of goal.
However, just as the Blucerchiati thought they'd done enough to take home the win, Mauricio Isla snatched a last-gasp equaliser.
The Chilean substitute gathered with his back to goal, spun round his marker in the box and placed a perfect snooker-shot into the far bottom corner.
It went to extra time and within two minutes the turnaround was complete, as German Denis was allowed a free header from point-blank range to nod in a touched-on Sanchez corner.
Moments later Daniele Mannini's angled volley was deflected inches past the upright.
Samp shot themselves in the foot, as the tension got to Daniele Dessena, shown a red card for sarcastically applauding the referee.
The home side were still unlucky, as Pazzini's free kick beat the wall and the goalkeeper, but clipped the top of the crossbar.
With time running out, the referee point to the spot after a clumsy Pasquale challenge scraped his studs down the back of Poli's thigh. Pazzini stepped up to convert, sending Belardi the wrong way.
Da Costa used his legs to beat away a Sanchez strike, then leapt to palm an Isla chip out from under the bar.
In the final minute of extra time, Gokhan Inler was tripped in the D. The Sanchez free kick whistled just wide for the last chance of the game, as it had to be decided on penalties.
Both sides had a 100 per cent record from the spot until Reto Ziegler ballooned over the bar. A Denis conversion would win it for Udinese, but Da Costa stuck up a hand to parry.
Pazzini took the Blucerchiati's last penalty and buried it confidently, so on 4-4 it went to sudden death.
Da Costa saved his second consecutive kick, beating away Isla's attempt. Fernando Tissone kept his nerve to audaciously chip the goalkeeper and send Sampdoria through to the quarter-finals.
They'll face the winners of Thursday's Milan-Bari tie.
Penalties: Sanchez (U, goal), Mannini (S, goal), Abdi (U, goal), Pozzi (S, goal), Inler (U, goal), Guberti (S, goal), Armero (U, goal), Ziegler (S, miss), Denis (U, saved), Pazzini (S, goal), Isla (U, saved), Tissone (S, goal)
Sampdoria 2-2 Udinese (aet, 7-6 on pens)
Scorers: Macheda 32 (S), Isla 90 (U), Denis 92 (U), Pazzini pen 109 (S)
Sampdoria: Da Costa; Dessena, Lucchini, Gastaldello (Volta 52), Ziegler; Mannini, Poli, Palombo (Pozzi 93), Guberti; Macheda (Tissone 73), Pazzini
Udinese: Belardi, Angella (Armero 39), Zapata, Coda, Cuadrado; Badu (Isla 76), Inler, Abdi, Pasquale; Di Natale (Sanchez 46), Denis
Sent off: Dessena 99 (S)