Northampton Town 3 Carlisle United 2
But Gray could have done without a heart-stopping finale which almost saw the home side throw away a 3-0 lead.
Coasting thanks to a double strike from top-scorer Scott McGleish, who was taking his tally to 12 for the season as well as Andy Kirk's first goal for three-and-a-half months, the wheels almost fell off the home bandwagon.
Goalkeeper Mark Bunn pulled off two brilliant second-half saves to deny Danny Livesey's far-post header and a fierce low drive from Danny Graham, which appeared to have gone passed him before he clawed it back, but even Bunn was beaten by a strike in the final ten minutes by Graham and Kevin Gall.
The first half was a largely forgettable affair, although Keiren Westwood made a brave stop from McGleish after 19 minutes. Then, a minute before the break, a pass by Bradley Johnson picked out Kirk and his sweet right-foot volley found the top corner.
It was 2-0 just a couple of minutes after the break, although Carlisle's defenders claimed that McGleish had handled a fiercely-driven volley by Eoin Jess before bundling the ball over the line from close-range.
The home side then threatened to run riot with McGleish denied by a diving Westwood before a header by the same player flew just wide.
The Cobblers eventually made it 3-0 with 19 minutes left when a spectacular volley from 25 yards by Jess was parried away by Westwood into the path of McGleish, who made no mistake with the rebound.
This was the cue for Carlisle to hit back with Bunn saving brilliantly from Graham before the same player reduced the arrears with nine minutes left after Gall's shot had been blocked by the goalkeeper.
It was Gall who made it 3-2 after 86 minutes, slamming the ball into the roof of the net, but Northampton almost restored their two-goal advantage a minute from time when Bradley Johnson's drive from the edge of the box came back from a post.