Accrington Stanley 1 Gillingham 0
The former Liverpool trainee sent Stanley, who had a battle with the taxman earlier this season, into round four for the first time in more than half a century with his first goal in ten months just nine minutes from time.
The League Two side will now face the Cottagers in a clash that is expected to earn the minnows a much-needed six-figure sum.
Stanley flew out of the traps and would have been a couple of goals up inside the first 20 minutes had it not been for wasteful finishing.
In the 12th minute Dean Winnard's cross found striker Robert Grant in the box but the striker's shot was deflected wide by the stretching Tom Wynter.
Grant went close again before strike partner Michael Symes fired wide and lively winger Sean McConville failed to test Gillingham goalkeeper Alan Julian.
The Gills finally came to life on the half hour when Chris Palmer smashed wide and Josh Gowling also headed over.
The visitors cause wasn't helped when influential midfielder Curtis Weston hobbled off on 34 but they improved after the break.
And they should have been ahead five minutes after the restart but Mark Bentley's close-range effort was somehow kept out by on-loan Liverpool keeper Dean Bouzanis.
The young Australian also denied hot-shot Simeon Jackson and John Nutter as Gills came back into the game, but Stanley got a second wind in the final 20 minutes.
Leading scorer Symes tested Julian on 72 before Billy Kee flashed a decent shot wide soon after as Stanley piled on the pressure.
And the deadlock was finally broken on 81 when Miles fired home from the edge of the box.
Gillingham piled forward in the closing stages but failed to force an equaliser as Accrington held on for a famous win.