Dale Holland was Cork City's hero as his cool 89th-minute strike gave the First Division outfit a 3-2 win at The Showgrounds against top-tier opponents Sligo Rovers.
Beineón O'Brien-Whitmarsh and Dylan McGlade also scored in a famous result - McGlade netting from a second-half penalty - against a Sligo side who got a double from Romeo Parkes.
City came into this last-32 tie as obvious underdogs when comparing their second-from-bottom status in the First Division with Sligo's third-from-top position in the Premier Division.
Indeed, Cork manager Colin Healy admitted in the build-up that their assignment in Sligo would be "a very difficult game".
The visitors, without a win since June 18 and having only won one of their last six First Division fixtures, headed to the north-west without Cian Bargary and Rob Slevin, both still recovering from injury, but Josh Honohan returned for his first start of the season.
Liam Buckley's Sligo, despite their current Premier Division placing, were in the middle of the first major blip of their other progressive 2021 campaign – three defeats in succession, although two of these losses came against Iceland's FH Hafnarfjordur in the UEFA Europa Conference League qualifiers.
The hosts, whose standouts this season have been two ex-City players, Greg Bolger and Garry Buckley, welcomed Bolger back after suspension.
City were under pressure from the off but fortunate that Sligo's top scorer Jordan Gibson pulled a shot wide after two minutes.
Gibson did better three minutes later, with a firm connection, but City netminder Mark McNulty was equal to the effort.
But it was an error from Mark McNulty that led to Sligo's 13th-minute opener. Bolger's lofted delivery from the right was dropped by the custodian and Parkes gobbled up the chance, an unexpected gift, for his fifth goal of the season.
In warm but not oppressively hot conditions, City struggled to threaten Sligo during the opening period.
Buckley's long ball released goalscorer Parkes, who showed good skill to fashion a 24th-minute shooting chance only for the door to be firmly shut by Cork centre-back Jonas Hakkinen.
Against the run of play City equalised in style after 28 minutes. Ronan Hurley clipped in a teasing cross and O'Brien-Whitmarsh netted with a superb volley.
Sligo, rocked by the leveller, created further chances - Mark Byrne glanced a header wide and Regan Donelon got a shot on target.
Bolger also fired a ball goalwards but a deflection took the sting out of it and McNulty gathered comfortably.
A wonderful save at the end of the first half from McNulty, when he clawed away Gibson's looping goalbound header, kept City level going into the second half.
Matters took a remarkable twist when City were awarded a 55th-minute penalty when Cian Murphy was adjudged to have been fouled when trying to get to Cian Coleman's cross. Sixty seconds later McGlade's flawless spot-kick conversion put City 2-1 up.
Sligo remained flat, however, with City coping admirably until the 70th minute when Parkes goaled with a deft finish from a Bolger pass.
Sligo, though, were punished for not building on this leveller. A rare Cork attack led to substitute Dale Holland sweeping a fine shot home to the bottom corner from outside the area.
There were 10 minutes of added time, with City remaining resilient despite desperate Sligo pressure.
McNicholas; Banks, Blaney, Buckley (Kane 76), Donelon (Horgan 72); Bolger, Morahan (Keogh 46); Byrne (Kenny 90+3), Cawley (Figueira 90/+3), Gibson; Parkes.
McNulty; Beattie (Holland 49), Honohan, Hakkinen, Hurley; Byrne; Coleman, Crowley; McGlade, O'Brien-Whitmarsh (Walsh 90+5), Murphy.