Ten-man Cardiff put up a superb defensive display to earn three vital points with goals from Ross McCormack and Peter Whittingham securing a 2-1 win over Leicester.
Steve Howard struck a second-half goal to give the visitors hope but the Bluebirds held out.
Cardiff went ahead in the 10th minute with a fifth goal of the season for McCormack.
Stephen McPhail and Whittingham combined down the left and when the cross went in, the Leicester defence failed to clear and McCormack was on hand to prod into the net.
Two minutes later a loose pass found Chris Burke but he dragged his shot across goal.
Midway through the half only a superb sliding tackle from Paul Quinn stopped Dany N'Guessan from bearing down on goal and the Bluebirds were under pressure as Leicester forced a couple of corners.
McCormack thought he had doubled the score in the 27th minute when he headed back across keeper Chris Weale only to find Andy King clearing from the goal- line.
Adam Matthews replaced the injured Darcy Blake ten minutes before half-time with Quinn moving into the centre of defence.
City doubled their lead just before the interval. Weale pushed away a shot from McCormack and Gavin Rae gathered the loose ball before tapping back to Whittingham who guided in his 22nd goal of the season.
There was still time for a scare in the home goal when a Martin Waghorn corner seemed to go over the line but referee Fred Graham waved play on and City went in at the interval with a two-goal cushion.
Howard replaced N'Guessan for the second half as Leicester looked to exploit the centre of Cardiff's defence and they started off by attacking the home goal but David Marshall made a superb stop from a Gallagher shot.
Howard reduced the deficit from close range in the 52nd minute as the Bluebirds failed to clear a Waghorn corner.
Kennedy limped off to be replaced by Tony Capaldi on the hour as City's makeshift defence worked hard at keeping the Foxes at bay.
Disaster struck the Bluebirds in the 70th minute when Gabor Gyepes was sent off for bringing down substitute James Vaughan just outside the area but Gallagher screwed his free-kick well wide.
The final minutes had the Bluebirds defending but they hung on for a vital victory.