A brace from striker Sam Joel looked to have earned David Lowe's side a share of the spoils but the Welsh side struck in added time at the end of the match to claim the victory.
In hot and humid conditions the game was slow to get going at Brockhall, with little between the two sides.
But after Sam Joel had seen a goal-bound shot deflect wide on 42 minutes, the forward was then upended in the area by two Cardiff City players a minute later. Joel brushed himself down to make no mistake from the spot.
However the was still time for the visitors to level before the break, firing home from close-range after good approach play down the right.
15 minutes into the second half the Bluebirds took a 2-1 lead. Hesitant defending at the back from the young Rovers allowed a Cardiff man to nip in and score.
Attacker Stuart Callaway was brilliantly denied by the City goalkeeper with 7 minutes remaining as Rovers pressed for an equaliser.
Then two minutes from time Rovers thought they had earned themselves a draw when Ryan Nyambe's cross was dummied by Callaway, and that allowed Joel to sweep the ball home for his second of the match.
However that joy was short-lived as the visitors grabbed the winner a minute into injury-time, when having failed to clear their lines on a number of occasions, the Welsh club worked the ball into the back of the net to seal the win.