Shaun Whalley’s penalty was superbly saved by Tranmere keeper Mateusz Hewelt to send Rovers through to the second round of the Carabao Cup after a mammoth shoot-out.
First half goals from Kody Adedoyin and Ryan Astley, his first Stanley goal, gave the Reds a 2-0 half-time lead.
Tranmere got one back after the break before an agonising 93rd minute equaliser from Paul Lewis took the game to penalties.
In the shoot-out, Joe Pritchard had his spot kick saved by Hewelt while Lukas Jensen kept out Rhys Hughes to take it to sudden death.
All the other penalties were scored and the players were taking their spot kicks for the second time when Whalley was denied to make it 12-11 on penalties to Rovers and knock Stanley out.
It was agonising for the Reds who had most of the opportunities, especially in the first half. Pritchard had the first real chance, his strike from the edge of the area taking a deflection and flying just over the bar on six minutes.
Astley came close on 16 minutes but his header, from a Sean McConville cross, was narrowly over the bar.
From a McConville free kick on 27 minutes, Pritchard had an effort blocked, it came back out to winger McConville who forced a save out of Hewelt and then Tommy Leigh’s follow up was blocked.
Stanley piled on the pressure and put a number of dangerous balls into the box but couldn’t capitalise until two goals in two minutes changed the game.
The Reds opened the scoring on 37 minutes when Tranmere lost the ball in midfield and Adedoyin nipped in, raced forward and weaved his way past the defence to slot home into the far corner for a superb solo goal. It was his second goal in three games.
It was two on 39 minutes when Everton loan defender Astley got the ball with his back to goal on the edge of the area, hit it on the turn and, via the inside of the post, it rolled into the net.
Jensen’s first real save came in injury time when he kept out an effort from Josh Hawkes with his legs.
Pritchard came close to increasing Stanley’s lead after the break but his close range diving header was narrowly over the bar.
However Tranmere came back and, after a quick break upfield on 62 minutes, Hawkes got the ball and he tricked his way into the area and fired home.
Stanley continued to press as they looked to regain their two-goal cushion and then, in the third and final minute of added time, Tranmere attacked and ex-Red Joel Mumbongo headed the ball on and it fell to Lewis at the far post who slid it home to take it to the shoot-out - and a cup exit for the Reds.
Stanley: Jensen, Clark, Astley, Rodgers, Longelo (Sangare), Martin (Coyle), Pritchard, McConville, Leigh (Pell), Lowe (Whalley), Adedoyin (Woods)
Subs: Savin, Perritt, Procter, Conneely
Attendance: 1035 (326 from Tranmere)