When Castletroy kicked a penalty four minutes into the second-half from Stephen Atkinson to stretch their lead to 17-7 the Limerick outfit looked set to secure victory.
But just when it seemed as if their Bandon hosts would have to settle for another game through the back-door, they produced a scintillating spell that yielded three magnificent tries and a place in the quarter-finals.
Castletroy led at the interval thanks to two wonderful tries from centre Paul Clancy, both converted by Atkinson, against a single try from Bandon.
There was little between the sides in that opening spell, with Bandon relying heavily on number eight Robin Stokes and skipper Colin Deane as well as a forceful rolling maul.
However, all their early work was undone by the direct and hard running Clancy, who stole the show in that opening half.
The centre got his first try against the run of play after 10 minutes - sprinting 50 metres past a Bandon defence which looked somewhat disorganised while centre Ethan Greene was down injured.
The additional points gave Castletroy a 7-0 lead but Bandon fought back bravely. Greene missed a kickable penalty but three minutes from the interval, the captain Deane forced his way over and Greene converted.
But, just as quickly as they had fought their way back, Bandon tried to make too much of a very optimistic attacking opportunity deep inside their own territory. Castletroy scrapped to win back possession and Clancy was sent racing away for his second try, also converted by Atkinson, for a 14-7 interval advantage.
But, as the game drifted into the final quarter, Castletroy were put to the sword. The comeback started when Bandon winger Victor Lovell finally went over in the corner after a spell of heavy pressure.
That came 12 minutes from the end and Travis Coomey sent hearts racing when he surged over for a try under the posts that Greene converted to give Bandon the lead for the first time.
At 19-17, there was a spring in Bandon’s step and their star performer – there were several fine efforts in the forward unit – Stokes and others ensured there was to be no yielding. Instead, they finished even stronger and Sean Hudson grabbed the fourth try two minutes from the end to leave his side worthy winners.
S Hudson, V Lovell, B Gur, E Greene, H Hall, E Palmer, J Crowley, J French, T Coomey, A Deane, C Scully, J Bradfield, N Beamish, C Deane (captain), R Stokes.
M Archer, A O’Connor, D Ogden, P Jackson, B Hayes, S Minihane, J Donnelly, B Hodgins, T Beare, J Brady, B Matthews, N Barker.
E Murphy, B Richardson, P Clancy, A Kennedy, M Rowsome, S Burns, S Atkinson, A Myers, K O’Shea, M Bromell, R Keaveney, G Bourke, E O’Shea, C Bermingham, S English (captain).
S Finnucane, B Sheehan, C Flannery, J Coates, S Devitt, S Mulkern, J Johnson, S Morgan, S Madden, L Callinan.
C Harrington (MAR).