The Cobblers remain in the bottom two but the three points keeps Chris Wilder's men in with a fighting chance of surviving the drop.
The visitors scored the only goal after a dream start. Chris Hackett got to a long crossfield ball first on four minutes and the right winger rounded outrushing goalkeeper Marcus Bettinelli and slotted home from a tight angle.
Stanley pressed without finding an end product with striker James Gray the closest when he had goalkeeper Matt Duke beaten but his shot sailed just wide of the far post.
The Cobblers should have doubled their lead on the stroke of half time when Emile Sinclair caught on-loan Fulham stopper Bettinelli out of his goal but the wideman took too long and Tom Aldred got back to block his goalbound effort.
It was scrappy after the break but Sinclair could have orchestrated a second when he broke on the left wing and played in a cross which Dean Winnard cleared with John Marquis waiting to pounce.
However Lee Molyneux almost celebrated a leveller for Stanley just after the hour mark area but fired inches wide.
Marquis came close for the visitors while Duke pulled off a superb save to deny Kayode Odejayi in injury time as Northampton held on for a precious win.