Two close range finishes in 10 minutes from Julien de Sart and Darren Bent saw Steve McClaren’s side establish a two-goal cushion early doors, but when they seemingly held total control, the visitors halved the deficit through Kedeem Harris’ strike from distance out of nothing.
As the contest’s pendulum swung, the Bluebirds scored two goals themselves in a strong start to the second half – through Harris and Craig Noone – to lead 3-2, before Bent’s glancing header levelled matters once more.
Joe Ralls scored the game's decisive goal as the game entered added time, however, scoring the winner from the penalty spot after Rhys Healey had been upended in the area as Neil Warnock’s side claimed a second successive win on the road.
A chaotic finish was the last thing anyone expected after the comfortable start the Rams made to their second home game in four days as they faced a Cardiff side who were all too happy to sit deep under the Pride Park floodlights as proceedings began.
Against Leeds United, the Saturday previous, the visitors had only had a 29 per cent share of the possession over the course of the afternoon, but that had no relevance on the outcome as they ran out 2-0 winners over the promotion hopefuls on their own turf.
The Bluebirds initially adopted the same defensive attitude for this fixture and the onus was entirely on Derby to ask the questions.
Bossing possession, McClaren’s men were patient in their approach, but two goals early doors saw Cardiff’s game plan thrown out of the window.
From a corner, won off the back of a clever dummy by Bent, Tom Ince swung the ball on to head of Alex Pearce. The defender rose, sending a header towards goal that was palmed away by Allan McGregor into the path of de Sart, who placed the ball into the back of the net.
The second blow came 10 minutes later. Ince was involved again, picking out Bent, who made the most of some confusion between Matthew Connolly and McGregor to bundle in his sixth goal in as many outings.
Harris forced Scott Carson into a good save no more than a minute later, but that aside the Rams were in cruise control.
There was plenty of chances to add to the scoreline for the hosts too. Bent saw a shot blocked, Ince was denied by McGregor and Will Hughes saw a looping effort from the edge of the area deflect off a blue shirt and out for a corner.
There had been no sign of a comeback from Cardiff, but with four minutes of the first half remaining, Warnock’s men gave themselves a lifeline as Harris took aim from range, sending a shot into the back of the net via a deflection off Pearce.
The pendulum swung. Cardiff grew in confidence as they sought to go into the break on level terms as jitters began to creep into Derby’s game. The closest they came before the interval, though, was through Kenneth Zohore, the lone frontman, who was thwarted by Carson.
It proved only to be a brief reprieve as the Bluebirds levelled matters, making the most of Aron Gunnarsson’s giant throw into the area as Harris capitalised on a defensive error.
It got worse 10 minutes later, as Noone produced a moment of magic to turn the game on its head as he collected the ball on the edge of the area, took a touch and smashed an effort into the far corner with his second.
It could, and should, have been four shortly after the hour too. It came from a Derby corner, which was half cleared to the right side. Zohore took advantage of a rash challenge from Marcus Olsson, slipping the ball beyond the left back, to lead a four on two breakaway. Instead of passing, he took the shot himself, firing it straight at Carson.
Passing up the opportunity left Warnock with his head and his hands on the touchline as the Rams got themselves back on top to set up a grandstand and chaotic finish.
Jacob Butterfield went within inches of his first goal of the season to kick start a period of dominance for the hosts, whilst Johnny Russell, the substitute, saw a header cleared off the line.
The equaliser did come shortly after that, though, as Bent notched his fourth goal in two games by glancing Olsson’s cross from the left beyond a flat-footed McGregor.
On level terms, with plenty of time on the clock and in the ascendancy, Derby threw everything in search of what would prove to be a late winner and whilst there was one final twist in the tale, it didn’t go as expected.
On his own up front, Healey, on as a late substitute, collected possession deep inside Derby territory and with Pearce closing in. The young forward shifted the ball past the defender, made his way into the area, before tumbling under pressure.
Stephen Martin, the referee, reacted immediately and pointed to the penalty spot and up stepped Ralls, who sent Carson the wrong way to score the contest’s seventh goal as the Rams’ 11-game run at Pride Park came to an abrupt end.
Derby County: Carson, Baird (Russell, 65), Keogh (C), Pearce, Olsson; de Sart, Hughes (Nugent, 66), Butterfield (Blackman, 90); Ince, Anya, Bent
Substitutes not used: Mitchell, Christie, Shackell, Johnson
Cardiff City: McGregor, Connolly, Morrison, Bamba, Richards; Ralls, Halford (Healey, 80); Noone (Hoilett, 85), Gunnarsson, K. Harris (John, 88); Zohore
Substitutes not used: Murphy, Bennett, Whittingham, M. Harris
Attendance: 26,541 (308 away supporters)