Ryan Lowe's brilliant volley earned Crewe their fourth win in five to move them within two points of the top six.
Lowe blasted home in the 59th minute for his fifth of the season to brighten a dismal game.
Northampton laid siege to the home goal in the closing minutes, which included five minutes of added time, but Crewe, for whom centre-half Julien Baudet was outstanding, held firm to claim the three points.
Baudet produced the outstanding moment of the first half when he thundered a free kick onto the post after Guy Branston caught Lowe 30 yards out.
Branston, on loan from Peterborough, earned a yellow card for that challenge and was in the wars when he clashed heads with Crewe's loan striker Cedric Baseya, who was also making his debut.
The Southampton youngster was way off the pace in the first half as he stumbled about up front as the Railwaymen failed to conjure up a meaningful threat.
Northampton weren't much better, although Andy Kirk headed a Colin Larkin cross just over.
Gary Roberts' angled drive was kept out at the near post by Mark Bunn's feet just before the break.
Fortunately, both sides stepped up a gear in the second half and Lowe capitalised on Liam Dolman's poor clearance to flash a volley into the bottom corner for the decisive goal.
But Crewe had a real escape 12 minutes later when Andy Holt crashed a low drive onto the post and substitute Bradley Johnson should have levelled, but planted a free header from a corner over from close range.
Crewe were under real pressure in the closing minutes and after they failed to clear a free kick, Dolman's fierce rising drive from ten yards out was turned over the bar acrobatically by keeper Ben Williams.
Crewe technical director Dario Gradi said: "I told the players at half-time it might be a 1-0 game and we would have to defend well and the back four was excellent.
"Julien Baudet was outstanding and Northampton couldn't get past him."