Ashby, playing his first game in three weeks after a shoulder injury, put through his own net in the 22nd minute.
Gillingham twice hit the woodwork in the second half.
But Eagles, on loan from Manchester United, scored his first goal for Watford with the last kick of the game to wrap up the win for the hosts.
Gillingham boss Stan Ternent on his side's lack of luck:
"We were awful in the first half, we didn't turn up and you need to give it a go in our situation.
"In the second half we hit the woodwork a couple of times, their keeper made a very good save and we had other chances we should have put away.
"Then with the last kick, they scored a second goal. When you're down, you have to accept you don't get much luck."
Watford: Jones, Doyley, Cox, Demerit, Darlington, Devlin (Eagles 79), Mahon, Jackson, Ardley, Helguson, Webber (Dyer 87).
Subs Not Used: Chamberlain, McNamee, Bouazza.
Goals: Ashby 23 og, Eagles 90.
Gillingham: Brown, Nosworthy, Ashby, Cox, Rose (Roberts 84), Southall, Smith, Flynn, Crofts, Byfield, Henderson.
Subs Not Used: Hills, Bossu, Pouton, Beckwith.
Ref: A Hall (W Midlands).