In a game of few clear cut chances, Gilmartin should have easily saved Barnes' 20-yard effort, which came straight at him, but the Hornets goalkeeper spilled the ball into the net.
An uncharacteristically subdued Watford side nearly fell further behind but Gilmartin managed to make a fine save from Chris Wood's strike.
The striker then headed against the crossbar after the interval before the hosts finally asserted themselves.
The closest they came to an equaliser was substitute Will Buckley's strike from 12 yards, which was parried by Peter Brezovan.
Danny Graham missed the target with a couple of opportunities as Watford pushed forward for an equaliser but League One leaders Brighton valiantly held on to claim a place in the last 16.
Watford had been on a fine run of form of late although a 2-1 defeat to promotion rivals Cardiff ended their seven-match winning run.
The Seagulls had been equally imperious with five victories in six.
It was therefore a slight surprise when the fourth-round clash began in a scrappy manner, although both teams made four changes to their starting line-ups.
From out of nowhere though, Barnes gave Gus Poyet's men the lead in the 16th minute following a mistake from Gilmartin.
Gary Dicker's centre was chested back by Chris Wood to Barnes and the striker's shot from just outside the area was fumbled into the net by Gilmartin.
It was a howler from the Irishman but he made amends six minutes later with a scrambling save at his near post from Wood's close-range effort.
Malky Mackay's men had won their last five games at home but they were certainly under the cosh in the first-half.
The visitors, who had knocked out Watford's Championship rivals Portsmouth in the last round, failed to capitalise further however, with long-range efforts from Inigo Calderon and former Hornets loanee Liam Bridcutt the closest they came to doubling their lead.
Wood had an excellent chance seconds after the interval but when he had escaped his marker, the striker's header hit the top of the crossbar.
Watford finally had their first shot of the match when Martin Taylor brought the ball forward from defence and after he played a one-two with substitute Matthew Whichelow, he could only manage a tame shot from 12 yards, which was comfortably saved by Brezovan.
The hosts continued to push forward though Stephen McGinn, Whichelow and Graham all missed the target with long-range efforts.
Buckley was put clean through on goal but his shot was superbly parried by Brezovan.
Brighton weathered the storm though and Calderon and Glenn Murray had chances to kill the game off but they were equally as wasteful as their Watford counterparts.