Liam Delap had given City the perfect start with a 17th minute opener only for Rovers to level through Danny Lloyd.
City twice hit the woodwork, but our task was then made even harder by the second half dismissal of Luke Mbete.
And two minutes from time Tranmere booked their place in the last 16 when Ollie Banks converted from the spot after Romeo Lavia was adjudged to have brought down Kieron Morris.
There was a novel backdrop to the game with fans allowed back inside Prenton Park with the Wirral-based League Two club falling within Tier 2 of England’s COVID-19 system.
For the City youngsters it was their first experience of playing in front of spectators in almost nine months and their presence added an extra frisson to the game.
Despite driving rain and a lashing wind, City almost made the perfect start.
On seven minutes it was Rovers turn to threaten as Sid Nelson’s header from Danny Lloyd’s corner flashed just the wrong side of Cieran Slicker’s goal.
But it was City who struck first in clinical fashion through Delap on 17 minutes.
James McAtee was the architect, his teasing left wing run and cross bamboozling the Rovers defence before drilling in a low ball which allowed Delap to demonstrate his predatory instinct and finish.
It should have been two within six minutes.
More Rogers magic turned Tranmere inside out and he found McAtee waiting in the centre of the box with a pinpoint cross, but the midfielder’s shot was wide.
And on 23 minutes City were left to rue that spurned chance as Rovers hit back to level affairs, Danny Lloyd rifling home a powerful half volley from 10 yards after latching onto Morgan Ferrier’s chest down.
In what was an action-packed affair City almost instantly regained the lead in stunning fashion, Delap superbly opening up space on the edge of the box before lashing a powerful shot which cannoned back off the post.
Delap then caused more mayhem, surging through past the keeper and squaring back for McAtee on 36 minutes only for the midfielder’s goalbound shot to be deflected over.
However, Rovers were also a serious threat going forward and Ferrier’s near post flick from a Lloyd was just inches away from the target.
City were then dealt a hammer blow on 56 minutes when Luke Mbete was shown a straight red card after a clash with Tranmere’s Paul Lewis on the edge of the box.
Reduced to 10 men and with Tranmere harrying at every opportunity it made a tough task all the harder for Maresca’s youngsters.
City though were not unbowed and we were denied by the woodwork once again on 62 minutes when McAtee’s dipping free-kick clipped the top of the bar.
Tranmere substitute Otis Khan then drew a smart save from Slicker after weaving in from the left and unleashing a powerful inswinging shot as the hosts sought to use their numerical advantage.
With time running out and penalties looming, Tranmere then took the decisive lead from the penalty spot.
Referee Stockbridge ruled that Lavia had brought down Morris in the box and Ollie Banks rifled home the spot kick.
It was tough on City who had given their all but they could depart the competition with their heads held high.
How we lined up
Cieran Slicker was in goal and shielded by a back four of CJ Egan-Riley, Taylor Harwood-Bellis, Luke Mbete and Nat Ogbeta. Romeo Lavia was the holding midfielder with Ben Knight and James McAtee also in the midfield engine room. Liam Delap led the line up front with Morgan Rogers and Sam Edozie providing the width.
City return to Premier League 2 action on Sunday when we make the short trip to tackle Manchester United in an eagerly-awaited derby.
Kick-off is 1pm and CITY+ subscribers will be able to watch the game live as Maresca’s men bid to retain top spot.