Ivan Toney and substitute Marc Richards were both on target in the second half to leave the Robins a point off safety with two games left.
Former Cobblers striker Shaun Harrad had an early effort blocked while Lawson D’Ath shot wide at the other end.
Durrell Berry was off target for Cheltenham before the hosts began to create the better chances. Evan Horwood fired over from a free-kick, Diego De Girolamo twice tested goalkeeper Trevor Carson and Joel Byrom was just off target.
Matt Sparrow went close for the Robins on the stroke of half-time when he shot over from a free-kick.
After the restart D’Ath forced Carson to deal with his effort from the edge of the box while Girolamo had a shot blocked and Ricky Holmes was also denied by the visiting keeper.
Harrad struck the upright and Mathieu Manset shot wide for the visitors before Northampton broke the deadlock in the 57th minute when Toney beat Carson after being set-up by D’Ath.
Richards doubled Northampton’s advantage in the 70th minute when Holmes picked out the top scorer who beat Carson from close range.