Goals by Roger Johnson and Peter Whittingham helped the Bluebirds clinch a vital three points and, although Dele Adebola struck for the Robins, Cardiff fully deserved their win over the joint league leaders.
The Bluebirds showed two changes with skipper Stephen McPhail and Steve Thompson replacing Aaron Ramsey and the suspended Jimmy Floyd Hasselbaink.
Cardiff created their first goalscoring attempt in the 16th minute when Whittingham's free-kick was headed just wide by Johnson.
The Bluebirds were finding it difficult to make any headway against the strong wind but two minutes later Whittingham sent Thompson free only for his goalbound shot to be cleared off the line.
Play was scrappy with neither side able to carve out any clear-cut opportunities until just before the break.
It was in the 44th minute that the Bluebirds took the lead with a superb header from Johnson after a free-kick wide on the left taken by Whittingham.
Cardiff started the second half making full use of the conditions and Whittingham flighted a free-kick narrowly wide of an upright before Joe Ledley also went close with a neat lob.
In the 55th minute Cardiff should have extended their lead when they broke out of defence at speed but they failed to take advantage of their numerical superiority and the Robins cleared their lines.
In the 73rd minute Adebola equalised for the Robins with a header after Cardiff had allowed Jamie McAllister the time to measure his cross.
Five minutes later the visitors had the ball in the net again but this time referee Keith Stroud disallowed it for offside.
Back came Cardiff and McPhail was upended in the box in the 80th minute. Up stepped Whittingham but his spot-kick was saved by Adriano Basso only for the midfielder to run in and slide the rebound into the back of the net.
Robins boss Gary Johnson was sent to the stands after becoming involved in a furious argument with the fourth official and both sides went close to grabbing a winner in a hectic final ten minutes but the Cardiff defence held firm for a deserved victory.