A superb 25-yard strike from substitute Scott Neilson sent Crawley into the second round of the Johnstone's Paint Trophy with a 3-2 home win over League Two leaders Gillingham.
Neilson settled the issue four minutes from time with a dipping right-foot shot past debutant goalkeeper Tommy Forecast.
Crawley, who now boast six wins in seven league and cup games, were forced to battle hard for their victory after going behind midway through the first half.
Town midfielder Nicky Adams had an early shot charged down and also drove narrowly over from 25 yards before Bradley Dack headed Gillingham in front in the 22nd minute.
The unmarked Dack struck at the far post following a long throw from Chris Whelpdale.
Crawley defender Mark Connolly struck the post with a deflected drive before former Swansea left-back Joe Walsh levelled with a fierce drive from 20 yards into the top corner after 40 minutes.
Billy Clarke put Crawley ahead by neatly steering in a cross by Josh Simpson after 47 minutes, but Lewis Montrose' smart shot on the turn made it 2-2 just three minutes later.