Andy Robinson gave the well-drilled visitors the lead just before the break, converting from the spot after Harlee Dean brought David Amoo down.
The Bees hit back when Dean redeemed himself, getting ahead of marker to glance home Jake Bidwell's near-post free-kick.
But Adam McGurk skipped past two defenders to fire in a low angled drive at the near post for the winner after 66 minutes.
It was tough on Uwe Rosler's side who had the clearer chances, Marcello Trotta and Clayton Donaldson forcing good saves from keeper Owain Fon Williams.
The stopper was lucky to stay on the pitch after lashing out at Harry Forrester after the pair clashed in the box.
Tranmere were thankful for the referee's leniency as he went full length to deny Sam Saunders' goal-bound free-kick almost on full time.
Brentford pressed deep into six minutes of injury time when Dean almost levelled with a low drive, but his effort was blocked.