A brace from former England striker Rickie Lambert helped Cardiff move out of the Sky Bet Championship relegation zone with a 2-1 win at Rotherham.
Lambert headed Peter Whittingham’s inswinging cross home on 74 minutes, before he fired past Lee Camp with a deflected effort five minutes later.
The home side looked set to seal the win after taking the lead on the hour mark when Chelsea loanee Izzy Brown scored from Greg Halford’s long throw.
Rotherham boss Alan Stubbs said the players must keep working hard to turn things around.
“This is a tough one to take because we deserved more from the game than what we got,” he said.
“I can’t fault the players effort and desire because they are not getting the rewards that they deserve.
“We cannot afford to feel sorry for ourselves, the second goal sums up the bad luck we are having.
“Realistically we should be sitting on 12 to 13 points. We have to keep working hard and doing the work on the training ground.”
Rotherham had enjoyed the lion’s share of possession, with Danny Ward and Brown causing the Welsh side’s defence problems during a dominant first-half display.
But Alan Stubbs’ side were once again guilty of failing to see out the game as Cardiff came from behind to seal their first league away win of the season.
The defeat leaves United into the relegation zone after blowing the lead for the fourth game in a row.
Lambert had the first shot in anger with a long range free-kick on 14 minutes as both teams started slowly.
Dael Fry’s powerful shot was well saved by Ben Amos before Brown’s header was cleared for a corner by Sean Morrison.
Ward had a curling shot comfortably saved on 21 minutes as the Millers stepped up the pressure.
Ward then had an angled shot turned behind by a stretching Amos, before Brown fired just over after cutting through the Bluebirds defence.
Joe Ralls hit a thunderous effort a yard over Camp’s crossbar with Cardiff’s best chance of the half on 33 minutes.
Morrison failed to direct his header on goal on 37 minutes as Cardiff enjoyed a better spell of possession.
Morrison put his head on the line at the other just before half-time to clear Halford’s inswinging cross as Ward waited to pounce.
Ward and Brown combined well just after the restart to force another corner for the Yorkshire side.
Ralls tried his luck from distance on 54 minute as struggling Cardiff were limited to speculative long-range efforts.
City captain Morrison blocked another Ward shot as the former Huddersfield Town team-mates continued to enjoy a fine personal battle.
Rotherham finally went ahead when Brown pounced after Halford’s long throw created an opening on 60 minutes.
Morrison and Matthew Connolly both headed over as City looked for a quick response.
Kelvin Wilson missed a chance to wrap up the points when he headed straight at Amos on 70 minutes.
Lambert showed good strength to hold off Halford and Wilson as he headed over a minute later.
But he found the back of the net on 74 minutes to draw Cardiff level after heading home Whittingham’s free-kick.
And battling Cardiff completed an impressive turnaround when a Lambert shot deflected past Camp with 11 minutes remaining.
We have all the latest from today’s matches.... plus a new stats centre to quench your thirst for news from your club.