The hosts went ahead after three minutes of Tuesday night's encounter as Matt Fish's long ball was misjudged by Cobblers goalkeeper Lee Nicholls and McDonald tapped in from close range on his first start since returning to Priestfield.
After 18 minutes, Northampton almost levelled as Clive Platt's effort was saved by Nelson, before Ben Harding's effort was blocked on the line.
In the 36th minute the Cobblers had an excellent chance to equalise, Chris Hackett beating Joe Martin and whipping in a right-wing cross, but Platt could only head wide.
The wet and windy conditions made for a tight encounter in the second half as neither side was able to fashion many clear-cut chances, both teams having to resort to long balls.
But Gillingham made sure of the points in the 84th minute as Weston latched onto a long ball and smashed into the bottom right corner off the post.