Substitute Jennison Myrie-Williams scored the winner with his first touch to cap a thrilling comeback by Bristol City, who had trailed 2-0.
Shane Sherriff's deflected cross gave Rovers the lead and Paul McClaren drove home their second before half-time.
But Enoch Showunmi reduced the arrears after the restart and debutant Phil Jevons drilled home an equaliser.
Myrie-Williams tapped home after Steve Brooker's second-half chip came back off the post to give City the points.
Bristol City: Basso, Orr (Myrie-Williams 67), Carey, McCombe, McAllister, Murray, Skuse, Johnson (Keogh 86), Showunmi, Brooker, Jevons (Brian Wilson 67).
Subs Not Used: Weale, Russell.
Goals: Showunmi 48, Jevons 59, Myrie-Williams 68.
Tranmere: Hart, Sherriff, Goodison, McCready, Tremarco, Shuker (Ellison 75), McLaren, Harrison, Davies (Curran 84), Taylor, Zola.
Subs Not Used: Ward, McAteer, Jennings.
Booked: Tremarco, Taylor.
Goals: McCombe 25 og, McLaren 44.
Att: 10,822
Ref: P Melin (Surrey).