The Whites earned a morale-boosting 2-0 win in the Welsh capital.
Souleymane Doukara fired the visitors into a slender half-time lead, before a red card for Fabio Da Silva on 64 minutes should have made it a straight-forward win for the Whites.
But even then, Steve Evans's side struggled to put City to the sword, though Mirko Antenucci sealed the three points with a second goal late on to settle a feisty affair.
Prior to Doukara's opener, United had to withstand plenty of pressure from the hosts, and Gray believes that their capacity to grind out the win was the most impressive aspect.
"It was a hard-fought victory and we rode our luck a little bit; when you come to these places, that’s what you got to do, you have to dig in.
“Steve will be pleased with how his players dug in there and saw out the victory.”
Evans will be delighted with the result, given that the win came seven days after their abject 4-0 defeat at Brighton, in which all four goals were scored before half time.
But last night was another excellent response, having beaten Bolton Wanderers 2-1 on Saturday to alleviate the gloomy mood around the camp, and they now sit 15th in the Championship table, nine points clear of danger.