Former Cardiff striker Cameron Jerome's double helped complete a shock turnaround as Derby County beat his former employers 3-1 to hit the Bluebirds' automatic promotion hopes.
Cardiff had the better of an entertaining first half and led at the break after Callum Paterson slotted in Joe Bennett's cross from deep at the far post (28).
Derby were dominant after the break and survived another scare when Gary Madine scuffed his effort from eight yards, but minutes later Jerome levelled (69) following a horrible mix-up in the Bluebirds defence.
It was a similar story when Andre Wisdom robbed substitute Yanic Wildschut in the box and squared for Matej Vydra (82), and late on Jerome sealed victory when outmuscling Sean Morrison (90) before beating Neil Etheridge.
Cardiff remain a point above third-placed Fulham in the race for the second promotion place in the Championship, while Derby jump above Millwall and into sixth, two points inside the play-off places with two games to play.
Derby's newly-adopted 3-4-3 appeared to help them feel more at ease in the opening stages and they fashioned the first clear chance when Tom Lawrence met Andreas Weimann's cross, but after taking a touch was thwarted by an onrushing Etherington.
Cardiff responded with a spell of possession in the Rams' half and could have been awarded a penalty when the ball struck Bradley Johnson's outstretched elbow in the box.
Their frustration at that decision was short-lived, however. Marcus Olsson left Paterson to his own devices when Bennett flighted the ball to the back post from deep, and he fired in a well-struck opener.
Any Derby resurgence took until half-time to materialise, and they spent long periods of the second half camped in the Cardiff half.
But it was not until Etheridge dropped the ball from a Derby corner that they got their rewards, with Aron Gunnarsson's clearance returned to the box, where Jerome held off Morrison to level.
And they completed a turnaround few had been expecting eight minutes from time, when Wisdom robbed Wildschut and centred for top-scorer and substitute Vydra, surprisingly named on the bench, to smash home his 20th league goal of the season beyond Etheridge.
Cardiff passed up a fine chance to level when Kenneth Zohore's glancing header was met by Wilschut at the far post, but he looked back into the middle instead of going for goal and wasted the opportunity.
Derby would do no such thing from their next attack, with Jerome outmuscling Morrison far too easily when the two competed for a long ball forward, and the latter was left on his backside as Jerome strolled through to wrap up victory.
Derby County: Carson; Keogh, Davies (capt.), Forsyth; Wisdom, Johnson, Huddlestone, Olsson (Vydra, 60); Weimann (Pearce, 87), Lawrence (Hanson, 87), Jerome.
Subs not used: Roos, Palmer, Ledley, Nugent.
Cardiff City: Etheridge; Manga, Bamba, Morrison, Bennett; Gunnarsson, Ralls, Paterson, J. Ward (Wildschut, 74), Hoilett (Pilkington, 74), Madine (Zohore, 67).
Subs not used: Murphy, Peltier, Grujic, Mendez-Laing.
Yellow cards: Paterson, Manga, Bennett, Ralls
Referee: Andrew Madley