Robert Earnshaw has proved the ace in the Cardiff pack this season, and the speedy striker again came up trumps to pile on the misery for the relegation haunted Cobblers.
Earnshaw and his team-mates squandered a glut of early opportunities, but the Welsh international bagged the one that counted in the 58th minute, a smart overhead kick after Peter Thorne's header from an Alan Mahon cross had come back off the crossbar.
It was Earnshaw's 27th goal of the season and Northampton's ongoing drought at home meant it was enough.
A delighted Lennie Lawrence said: "I am very pleased we have got things back on track but we had to work hard for it and made heavy weather of the victory.
"We had enough chances in the first 20 minutes to kill off the match and because we didn't take them it was always on a knife edge." Cobblers boss Terry Fenwick has yet to taste victory after four games in charge and his side have now failed to score in losing their last six home games, a sequence which stretches back to late November and more than nine hours of football.
Fenwick said: "I am disappointed with the result but Cardiff are very strong and if we can produce this sort of performance against some of the division's lesser sides I know we can turn things around." He added: "We tend to have five-minute spells where we lose it, feel sorry for ourselves and show a soft side. We have to lose that habit." In that early burst, Cardiff's Graham Kavanagh saw a deflected shot strike the underside of the bar while Earnshaw volleyed over in the 29th minute when it seemed easier to score.
Northampton had their chances, with top scorer Marco Gabbiadini failing to capitalise on a poor backpass by Rhys Weston and newcomer Brent Rahim seeing a sweet chip from the edge of the box tipped over by Neil Alexander.