Derry City left it very late as two goals at the death earned the Candystripes passage to the FAI Cup quarter-finals at the expense of a tenacious Drogheda United outfit.
The game looked all-set for extra time as the clock ticked into the 90th minute but for the intervention of substitute Ciaron Harkin, who tapped home to deflate Drogs’ hopes.
And any lingering hope was dashed definitively in injury time as Drogheda committed men forward and were caught out at the back by fellow sub Stephen Mallon.
It was rough justice on a Drogs side who had competed well for long periods and had chances of their own to win the game.
Indeed, the game would have taken on a completely different complexion had referee Derek Tomney not shown leniency towards Conor McCormack early doors.
The Derry City captain badly mistimed a challenge that left Drogheda wing-back James Brown writhing on the ground and, briefly, unable to get on up.
The home bench called for a red card to be produced but Tomney opted instead for yellow, with Drogs captain Jake Hyland joining him in the book for his protests.
Drogheda continued to enjoy marginally the better of the opening quarter and they had the first gilt-edged chance of the match when Mark Doyle found room in the box.
The striker saw his shot from a tight angle blocked by McCormack but the rebound fell nicely for Brown who, perhaps still running off the earlier knock, flashed his shot across the goal and wide.
Moments later, the referee’s leniency aided Drogheda as Adam Hamill was pole-axed by Jack Tuite in the centre circle and, bizarrely, the free kick was awarded to the home side.
The opening quarter set the tone for the game, which was scrappy and niggly but with no small amount of physicality from both sides, but low on quality.
Derry did at least call Drogs keeper Ross Treacy, in for his first appearance of the season in place of David Odomosu, in action when Hamill stung his palms with a long-range drive in injury time.
Drogheda continued to threaten in the second half and looked particularly dangerous on the counter-attack with the pace and trickery of Mark Doyle.
The striker broke with speed and intent on the hour mark and, having turned the defence on their heels, fed Brandon Bermingham, and he curled the ball inches wide of the post.
Slowly Derry began to assert themselves and the introduction of Mallon and Harkin gave the visitors a great attacking threat.
Ibrahim Meite went close after being played in by Hamill and the former Wolverhampton Wanderers man just cleared the bar with a chip shortly afterwards.
The final quarter was Derry’s but the final ball always seemed to be lacking – until, that is, the final minute when a third substitute in Colm Horgan made his presence felt.
Using the full width of the pitch, Mallon worked the ball through for the overlapping Horgan to break into the box and Harkin beat Hyland to the near post cross and flicked home.
And as Drogheda went for broke in injury, they were undone once more as Meite slipped the ball through for Ireland under-21 winger Mallon and he fired into the roof of the net.
Drogheda United: Ross Treacy; Jack Tuite (Chris Lyons 64), Derek Prendergast, Hugh Douglas; Richie O'Farrell, Conor Kane, Mark Hughes, James Brown; Mark Doyle, Brandon Bermingham (Stephen Meaney 84).
Subs not used: David Odumosu (gk), Adam Wixted, Ryan O'Shea, James Clarke, Jordan Adeyemo.
Booked: Jake Hyland (13), Mark Hughes (25), Chris Lyons (69).
Derry City: Peter Cherrie; Eoin Toal, Cameron McJannet, Ciaran Coll, Darren Cole; Joe Thomson (Colm Horgan 73), Conor McCormack, Jake Dunwoody (Stephen Mallon 57); Ibrahim Meite, Adam Hammill, James Akintunde (Ciaron Harkin 57).
Subs not used: Nathan Gartside (gk), Orrin McLoughlin, Mark McChrystal, Ronan Boyce.
Booked: Conor McCormack (13), Ibrahim Meite (65), Joe Thomson (70).
Referee: Derek Tomney
Extratime.ie Player of the Match: James Brown (Drogheda United).