Scott Kashket’s injury-time goal salvaged Gillingham an FA Cup second-round replay against non-league Dagenham and Redbridge.
Josh Walker put Dagenham in front on 80 minutes when he seized on a pass from substitute George Saunders before slipping the ball into the bottom right corner.
But their joy turned to heartbreak when Kashket turned a cross from fellow substitute Jordan Green into the net from close range to the relief of the League Two strugglers.
The visitors created little in the way of meaningful chances and much of the action was played in the Gillingham half.
Junior Morias and Josh Walker both went close for the National League side before skipper Matt Robinson slammed his effort into the side netting following a corner just before the interval.
Gillingham improved in the second period and shots from Lewis Walker and Robbie McKenzie were thwarted by saves from home keeper Elliot Justham, but the trickery of Myles Weston and constant threat from Morias kept Daggers on the front foot until Kashket’s late intervention.