Jake Hyde's seventh goal of the season continued League Two leaders Gillingham's mini-slump while boosting Barnet's survival hopes.
Hyde's first-half strike sealed back-to-back wins to move the struggling Bees out of the relegation zone and left Gillingham with just one win in their last five league encounters.
After player-manager Edgar Davids and Ricky Holmes had threatened early on, Hyde fired the visitors into a deserved lead in the 19th minute with a 20-yard effort.
John Oster came close to doubling their advantage 10 minutes before half-time with a teasing free-kick and only a last ditch tackle from Joe Martin stopped Andy Yiadom from tapping home Davids' centre shortly after the restart.
Defender Matt Fish had Gillingham's only clear cut opportunity in the opening hour of the match and manager Martin Allen made a triple substitution to try and spark a reaction from his side.
Within minutes of coming on, Gills forward Adam Birchall forced Graham Stack into action with a low drive.
Stack then produced two spectacular saves late on to deny Chris Whelpdale and Deon Burton as Barnet held on.