Cardiff City boosted their play-off hopes and damaged Derby’s as the Welsh side won in front of a club-record crowd at Cardiff City Stadium.
The hosts led after a tight first half thanks to Bruno Ecuele Manga’s header.
Chris Martin’s scrappy equaliser early in the second half sparked the game into life with a flurry of chances.
The hosts pressed relentlessly and got their reward as Stuart O’Keefe slid the ball in from a corner to keep Cardiff within two points of the top six.
Defeat saw Derby drop to sixth, a place below Sheffield Wednesday, who won at Huddersfield.
For Cardiff, victory closed the gap between them and the Rams to two points and gave the home supporters ample reason to cheer.
A deal giving free tickets to fans buying or renewing season tickets prompted an attendance of 28,680, exceeding the stadium’s previous best for a Cardiff game, 28,018 for the 6-3 Premier League defeat by Liverpool in 2014.
The hosts thrived on the charged atmosphere, starting energetically and registering the game’s first shot with Joe Ralls’ volley wide.
Derby soon settled, however, and kept the ball for long periods with their five-man midfield stifling Russell Slade’s side.
For all their possession, the visitors failed to trouble Cardiff’s defence, and it was one of the Bluebirds’ back four who gave them the lead.
Peter Whittingham’s outswinging corner floated temptingly towards the back post, where centre-back Ecuele Manga timed his jump perfectly and headed the ball powerfully into the top corner.
Having failed to muster a shot on target in a blunt first-half display, Derby managed one four minutes into the second half with Martin’s equaliser.
After the striker’s initial shot was blocked, the ball ballooned into the air and Martin seized on the rebound before Cardiff keeper David Marshall to head in from close range.
The home side could have reclaimed the lead within seconds, but Craig Noone’s shot was well saved by Scott Carson.
Scott Malone was the next to test Carson with a neat half-volley as Cardiff upped the ante before eventually scoring their second goal.
Whittingham was the creator again, his corner nodded down by Sean Morrison into the path of O’Keefe, who scrambled the ball in from close range for a winning goal met with rapturous celebrations in the stands.
Cardiff manager Russell Slade:
“It was a very professional performance. There weren’t many chances but we made enough use of the ball to create enough chances to win.
“What pleased me most was that when Derby got themselves back into the game early in the second half, there was a great response from us and we got the all-important second goal.
“We’ve got a mountain-load of character and we showed that in front of a big crowd to win a big game.
“However the challenge remains to get into the top six. Despite winning, we are still a couple of points adrift and we are running out of games.”
Derby head coach Darren Wassall:
“We’re very disappointed, particularly on the back of such a good result against Nottingham Forest two weeks ago.
“It’s unacceptable to concede two goals from set-pieces. Our defending at home has been good but on the road it just hasn’t happened for us.
“The lads are hugely disappointed because there was very little in a game of few chances. But that just makes conceding two goals from corners all the more disappointing.
“We came out of the blocks quickly for the second half and Chris (Martin) was brave with the header for the goal and we all thought we would kick on from there.”