A Michael Chopra hat-trick fired Cardiff City to victory, but defensive lapses made it a tense last few minutes.
Chopra struck in the 22nd, 57th and 68th minutes, to give City a commanding lead, but Leicester City took advantage of a lack of concentration to net twice and take the gloss off a fine performance.
Dave Jones had cause for double celebration as it was his 500th match as a manager and his 200th victory.
The Bluebirds were forced to withstand severe pressure at the start of the match and it was not until the tenth minute that they mounted a sustained series of attacks.
Peter Whittingham had a fierce free-kick turned round the post by the visitors' keeper Paul Henderson and from the resulting corner Glenn Loovens rose to head just over the crossbar.
Midway through the half the home side were deservedly ahead following a foul on Riccardo Scimeca on the edge of the area.
Up stepped Chopra to rifle the ball into the roof of the net with Henderson grasping thin air.
Scimeca was replaced in the 35th minute after suffering a hamstring injury and Kevin McNaughton slotted into midfield in his place.
Joe Ledley and Steve Thompson both had chances to increase the lead as the first half drew to a close.
Straight after the interval Leicester should have levelled but Iain Hume skied his shot from in front of goal.
In the 55th minute, he again missed a gilt-edged opportunity by firing high and wide when well placed.
The Bluebirds made him pay for that miss by swiftly taking play down the other end of the field, where Chopra cleverly clipped the ball over the onrushing Henderson and into the empty net.
The home side were well on top and Leicester looked like a side struggling in the lower reaches of the Championship and it was a comedy of errors that gave Chopra his hat-trick.
Thompson forced Patrick McCarthy into a hasty back-pass but Henderson's clearance only reached the former Rangers striker. He slipped the ball to Chopra, who jinked his way past a defender before lashing it high into the roof of the net.
The gloss was taken off a good City performance when Patrick Kisnorbo headed a corner home in the 70th minute and when substitute Elvis Hammond poked in another in the closing stages it led to a hectic final few minutes, but the Bluebirds held out to keep their play-off hopes alive.