Adam McGurk ended Brentford's 13-match unbeaten run in League One with a superb solo effort at Griffin Park.
After a flurry of early chances for the home side, Andy Robinson put leaders Tranmere ahead from the spot after Harlee Dean brought down David Amoo.
Dean redeemed himself after the break when he was first to Jake Bidwell's free-kick and levelled the scores.
McGurk then slipped past two defenders before firing home and Rovers withstood late Bees pressure to secure the win.
The home side, beaten at home only once before kick-off this season, went close when substitute Sam Saunders' free-kick forced an excellent save from Owain Fon Williams, who had seen plenty of action early in the game to deny Marcello Trotta and Clayton Donaldson.
And they could not find a way through, despite six minutes of added time, as they slipped a place to fourth in the table as a result of Swindon's home victory over Shrewsbury.