Gus Poyet's side had been frustrated for 80 minutes by Bristol City's former England goalkeeper David James and looked like drawing a blank for the first time this season.
The 41-year-old had pulled off a stunning double save to deny Craig Mackail-Smith in the second half.
But unbeaten Brighton kept plugging away and were finally rewarded when Barnes tucked in his fifth goal of the campaign to secure a fifth win in six games.
The Seagulls started sluggishly, though, and City's Marvin Elliott had the first chance of the match when he headed Neil Kilkenny's corner straight at Casper Ankergren.
Kilkenny got a sight of goal moments later but his ambitious long-range shot flew wide.
Brighton eventually got into their stride and Ryan Harley hit a free-kick into the wall, Barnes fired over and Mackail-Smith's shot was deflected for a corner.
However, they did not trouble James until the 34th minute when Mackail-Smith's drive was comfortably dealt with.
Their best move of the first half, involving Harley and Barnes, ended with Craig Noone blazing over the top.
And at the other end Jamal Campbell-Ryce stung Ankergren's palms with a long-range effort before the interval.
Campbell-Ryce was a lively presence just after the break as well with a shot which fizzed over the crossbar and another effort well kept out by Ankergren.
But Brighton were denied by a superb double save from James just before the hour-mark.
Noone's shot was parried by the veteran keeper and the ball fell to Mackail-Smith a couple of yards out, but James spread himself to block the Scotland striker's effort.
Noone had another opportunity moments later but again his shot was too high, and substitute Kazenga LuaLua fired wide from long range.
James tipped an effort from Gary Dicker over the top but he was finally beaten 10 minutes from time when his defence failed to deal with a corner.
Inigo Calderon headed the ball back into a crowded goalmouth, James saved Mackail-Smith's initial shot but this time was helpless to prevent Barnes smashing the rebound high into the net.
The Seagulls could have had a second when LuaLua swung in a dangerous cross but Mackail-Smith's glancing header flew wide.
But they were indebted to Ankergren in the dying moments when he denied Brett Pitman an equaliser.