Leon McKenzie was spot on to end Northampton's run of five straight defeats in a 2-1 win at home to Gillingham.
The visitors took an early lead through Chris Palmer but Dean Beckwith equalised against his former club, leaving McKenzie to hit the winner from the penalty spot.
Palmer gave Gillingham a seventh-minute lead, rounding off a cleverly worked free kick involving himself, Kevin Maher and John Nutter. Facing a seventh straight defeat, Northampton hit back and Nathaniel Wedderburn volleyed just wide before Beckwith equalised in the 20th minute, powerfully heading home at the far post on his return from a three-match ban from Ryan Gilligan's corner.
McKenzie volleyed over and Andy Holt saw his near post header tipped over by Alan Julian before Northampton grabbed what proved to be the winner in the 40th minute. Matt Lawrence fouled Beckwith from a set piece in the box and from the ensuing spot kick McKenzie sent Julian the wrong way.
After the interval neither side created much. Gillingham striker Adebayo Akinfenwa headed over and then saw a shot on the turn saved by Chris Dunn but rarely threatened against his former club.