Gillingham’s unbeaten run came to an end on home soil.
The Gills tasted defeat for the first time in nine games as Barnsley edged Saturday’s League 1 match.
The result also ends a run of scoring in consecutive matches which, before the weekend, stood at 21 games.
George Waring’s strike, early in the second half, settled it.
Gillingham started the afternoon three points off the play-off positions and boss Justin Edinburgh made just one change to the starting XI, as Jermaine McGlashan swapped places in the team with Danny Galbraith.
Barnsley were playing their first game under new manager Lee Johnson.
A swirling wind and persistent rain made life difficult for both teams and neither goalkeeper was properly tested in the opening half.
Gills’ only chance on target in the first 45 minutes came off visiting defender Lewin Nyatanga, who deflected John Marquis’ header goalwards.
Chances from Bradley Dack and Cody McDonald had gone well wide.
Barnsley’s finishing was poor when they got a sight at goal with Conor Hourihane, John O’Sullivan and Josh Scowen all shooting way off target.
The visitors went ahead just before the hour mark when Waring slotted home after keeper Stuart Nelson was unable to hold onto Ben Pearson’s low drive.
Gillingham were down to 10 men at the time. Bradley Garmston was already off injured but the introduction of substitute Joe Martin appeared to be delayed due a problem with his shirt.
The Gills came close to levelling straight after but Gavin Hoyte’s low shot was deflected over the bar by Jermaine McGlashan, who had been in an off-side position.
Marquis fired over with seven minutes left and at the other end Nelson was at full stretch to tip O’Sullivan’s speculative effort over.
Captain Doug Loft dragged a shot wide in the dying minutes but McGlashan should have done better in stoppage time, after being picked out by Bradley Dack. His low shot was blocked by keeper Adam Davies.
Gillingham: Nelson, Hoyte (Galbraith 81mins), Garmston (Martin 58mins), Egan, Ehmer, Loft, Hessenthaler (Norris 67mins), Dack, McGlashan, Marquis, McDonald. Subs: G Morris, Legge, A Morris, Romeo.
Barnsley: Davies, Holgate, Cranie, Nyatanga, Smith, Lalkovic, Scowen, Pearson, Hourihane, O’Sullivan (Bailey 88mins), Waring (Oates 90mins) . Subs: Dibble, Williams, Lita, Hemmings, Berry.
Attendance: 5,905 (377 away)