Andy Campbell capped the first game of his loan spell from Middlesbrough by scoring Cardff's winner at Northampton.
Campbell repaid former Middlesbourgh boss Lennie Lawrence's faith in him with the decisive goal in a 2-1 win which continues Cardiff's push towards the play-offs.
Northampton looked dangerous early on and had a number of chances to take the lead but it was City who went ahead after 32 minutes.
Leyton Maxwell powered home a shot but two minutes later the home side were level through a cool finish from veteran Marco Gabbiadini.
However, Campbell grabbed Cardiff's winning goal in the 37th minute and Northampton knew their luck was out when Andy Legg headed Jamie Forrester's second-half effort off the line.
Cardiff lost Daniel Gabbidon to injury, but former Manchester City man Spencer Prior came on to guide the Bluebirds home.