Gillingham moved into the League Two play-off places with victory at Rotherham, whose hopes of going up are now all but over.
Rotherham are now six points behind seventh-placed Gillingham with only two games remaining.
The only goal of the game came 12 minutes from time as Andy Barcham's shot from just inside the area took a wicked deflection off Ryan Cresswell.
Ian Thomas-Moore had Rotherham's best chance but shot just over the bar.
Gillingham boss Andy Hessenthaler told BBC Radio Kent:
"After the weekend we needed to do something and we decided to go the way we did (seven changes). We came out with a fantastic result.
"It might have been harsh on a few players, I just felt it was great being on an unbeaten run but against Barnet we weren't at it. I'm the manager, I have to make these decisions.
"It would have been an injustice had we gone away without the three points."