Christophe Berra gave Town a massive three points with a header in added on time to take Blues within a win of the Play-Offs.
The Scotland international thumped in a header, his fifth goal of the season, from Aaron Cresswell’s cross to lift the roof off Portman Road.
Jonny Williams’ spectacular strike from 25 yards had pulled Blues level in the second-half after Patrick Bamford had scored for the visitors on 38 seconds.
Mick McCarthy stayed with the same side that beat Brighton at the weekend but Blues got off to the worst possible start when Craig Forsyth got down the left and Bamford converted his cross at the near post.
The Rams controlled the first 15 minutes but Chris Martin gave the home fans something to cheer when he picked up a yellow card, the former Norwich striker pushing Christophe Berra to the ground.
Berra had to be alert to clear from Johnny Russell’s cross, while at the other end Aaron Cresswell’s left foot strike from distance was beaten out by the Rams’ rearguard.
Dean Gerken saved low down after Bamford had broken clear as Steve McClaren’s side continued to carry a threat but the yellow carded Martin had an anxious look back at referee Fred Graham after a challenge on Berra, the official waving play on.
Richard Keogh headed clear as Daryl Murphy challenged for Williams’ cross as Town started to get a foothold in the game, Paul Anderson denied as he looked to test Lee Grant in the Derby goal.
Williams wasted a good crossing opportunity on the right, Grant cutting out the danger, the Crystal Palace loanee then on the receiving end of a number of heavy challenges as the half drew to a close with Craig Bryson going into the book seconds before the break.
Stephen Hunt couldn’t get his shot in when the ball broke inside the Derby box as the second-half got underway, George Thorne becoming the third Ram to be booked, Williams again on the receiving end.
Gerken came to Town’s rescue with a crucial save to deny Bamford as he wriggled free inside the Town box, then at the other end Williams got clear on the left and his cross looked destined to be headed in by Luke Chambers but the skipper couldn’t get enough on the ball to find the net.
Murphy almost conjured up the equaliser on the hour, his shot deflected wide by Grant before Town made two changes, Frank Nouble and Sylvan Ebanks-Blake on for Anderson and Hunt.
Williams became the first Blue to go into referee Graham’s notebook, the midfielder judged to have caught Thorne but on 68 minutes the 20 year-old exploded a right foot effort from 25 yards into the net to get the home fans off their feet.
Bamford sidefooted wide from Martin’s cross as the game opened up, Forsyth then hitting the post although it looked as though Gerken got a hand on it first even though a goal kick was given.
Conor Sammon replaced Bamford in Derby’s first change, Nouble joining the card collection for a foul.
The injured Chambers was replaced by Frazer Richardson for the last 15 minutes, Ebanks-Blake almost finding the net with a close range header as Town pressed for a second goal.
Forsyth was booked for what was interpreted as a dive on the edge of the Town box before Berra launched himself at Cresswell’s delivery to head home a sensational winner.