Hakeeb Adelakun was the last-gasp hero as Gillingham beat a determined 10-man Dagenham 3-2 in their FA Cup replay to reach the third round.
The hosts struck deep into stoppage time after the visitors had equalised late on through George Saunders.
With a home tie against 2021 FA Cup winners Leicester awaiting in the next round, both sides had chances in a hectic start.
There are only 14 places between the two teams and it was the non-league club who struck first.
Matt Robinson fired home a superb 20-yard strike in the 15th minute.
But Ipswich loanee Elkan Baggott leapt highest to level just before the half-hour mark.
Gillingham led for the first time when Max Ehmer headed home with 13 minutes left, and two minutes later Dagenham’s Harry Phipps was sent off for a studs-up challenge on Lewis Walker.
The visitors seemingly salvaged extra time when Saunders rounded Jake Turner and scored from a tight angle.
But there was late heartache when Adelakun finished off a flowing counter in the fifth minute of time added on.
Enjoy the convenience of having The Sunday Post delivered as a digital ePaper straight to your smartphone, tablet or computer.
Subscribe for only £5.49 a month and enjoy all the benefits of the printed paper as a digital replica.Subscribe