Lukas Jutkiewicz scored in the sixth minute of stoppage time to send Championship side Middlesbrough into the fifth round of the FA Cup at the expense of League Two Aldershot.
In a frantic last 10 minutes Jutkiewicz headed Boro into the lead but Danny Hylton slotted in his eighth goal of Shots' Cup run to level.
But, with seconds remaining, Jutkiewicz ran on to a long ball and slotted in.
Merouane Zemmama, Stuart Parnaby and Nicky Bailey also went close for Boro.
Shots keeper Jamie Young kept out efforts from all three, with Zemmama first to try his luck.
Bailey then latched on to Zemmama's lofted free-kick, but his effort was smothered by Young, before the visiting stopper blocked Parnaby's fierce strike.
Jutkiewicz finally broke the deadlock when headed in Adam Reach's cross, but Boro's lead was short-lived.
Hylton, this season's leading scorer in the competition and who was Aldershot's biggest threat all afternoon, appeared to have earned the League Two strugglers a home replay when he raced on to a through-ball and slotted in his eighth goal of the campaign.
But the Shots were denied the chance to take Boro back to the Recreation Ground when a long ball found its way to Jutkiewicz and he slid the ball beyond Young to settle the tie.
Middlesbrough manager Tony Mowbray:
"Managers only ever want a home tie and in an ideal world [in the next round] it wouldn't be someone from our league. I'd like to play a Premier League side or one of the lower-league teams who've done well today.
"The FA Cup starts getting exciting in the fifth round as you're one game away from the quarter-finals. Let's see who we get, if we play Manchester United or Arsenal the onus is not on us to break them down, it's on them to break us down and if they get frustrated every time a move breaks down we can counter.
"Either is suitable for us. A top team that we can frustrate or a lower league team we can give problems and try to get through to the next round."
Aldershot manager Dean Holdsworth:
"I felt we'd earned a replay, we've had a fantastic display of commitment from the players and we took our goal fantastically well. In the dying seconds we had it ripped away from us and that's a big blow for the players.
"This is a fantastic football club and there were some good players against us but we've held our own. [The players] will be very down in the dumps now because they deserve a lot more than what they got but we go back to work on Monday morning.
"The challenge for the rest of the season is to show exactly what they have done, home and away, and push on in the division."