Tranmere just edged a ding dong FA Cup tie to book a quarter-final place for the second time in four years.
Swansea gave it a real go and with any luck would have forced a replay.
They finished with ten men after having Alan Tate sent off in the 84th minute for a body check on Ryan Taylor. But there was little contact between the players and it seemed a very harsh decision.
Andy Robinson, who had a six-month spell with Tranmere earlier in his career, gave an immense performance for Swansea and was unlucky to be on the losing side.
Canadian under-21 international Iain Hume was outstanding for Rovers and scored a wonder goal in the 59th minute to settle the fifth round match.
Brad Maylett wasted a great early chance for the Swans when trying to feed Lee Trundle instead of having a go himself and at the other end, hard-working midfielder Alan Navarro was off target with a 20-yard drive.
Swansea went ahead in the 16th minute when Robinson turned Leon Britton's cross home at the far post.
Tranmere piled on the pressure. Navarro saw a shot blocked, before the home side were awarded a penalty on 23 minutes when Mike Howard pushed Eugene Dadi as he tried to reach a cross by Hume.
Taylor sent keeper Roger Freestone the wrong way as he netted into his right-hand corner. Trundle collected a yellow card for comments obviously made at the time.
It was an end-to-end affair. Trundle saw a 26th minute free-kick deflected over the bar for a fruitless corner while at the other end, Danny Harrison missed the target with a header from Taylor's corner.
Swansea almost regained the lead on the half-hour. An angled shot by skipper Roberto Martinez was deflected over home keeper John Achterberg and the ball only just drifted past the far post.
Dadi wasted a good headed chance from a Gareth Roberts centre on 34 minutes before Navarro was next in the book for a clumsy challenge on Martinez.
Dadi was off target with another header as Tranmere exerted strong pressure and Taylor blasted high and wide from the corner of the box.
Immediately after half time Rovers sent on defender Paul Linwood with Gary Jones going into midfield.
Swansea almost regained the lead in the 49th minute but Jonathan Coates just failed to get a touch to a throughball by Martinez and Achterberg gathered gratefully.
Coates headed off the line from a header by Jones following a Taylor corner in the 50th minute. Then Freestone saved with an outstretched leg from a Jones shot following a Taylor throw-in.
The winning goal in the 59th minute followed a bout of passing by Taylor and Sean Connelly.
Hume was given possession and advanced forward before netting with a superb left-foot shot into the top left-hand corner from nearly 25 yards out.
Dadi hit the top of the net with a good effort on 67 minutes, as the tie really came to life.
Izzy Iriekpen should have put the visitors level in the 69th minute after a mistake by Graham Allen but hooked his shot wide in front of a gaping goal.
Then the persistent Robinson saw an effort deflected for a corner.
Achterberg produced a terrific reaction save to dent Britton in the 71st minute when his shot took a deflection.
Swansea, despite being down to ten men, refused to throw in the towel. Merseysider Trundle raced clear in the 87th minute but his angled shot passed just outside the far post.
After the game Tranmere boss Brian Little said: "It was a very even contest which was not surprising with such a prize at stake.
"It took a piece of brilliance to win it. It was a marvellous goal.
"It was a hard game and we just about edged it. We had to gather ourselves after going behind, but we got better as the game went on.
"It shows the character in the side but we've got to learn to start better. I felt the penalty decision was right but I was surprised by the sending off. I did not see anything at all. It was not malicious in any way." Tate said he was devastated by his sending off. "Their player did not go down and there was no malice in the challenge," he claimed.
He said he hoped the referee would have a look at a tape of the incident and downgrade his decision to a yellow card.
"We gave it a terrific go, but it was a brilliant goal that won it and you have got to praise the scorer," Tate added.
Swansea boss Brian Flynn said: "We gave it a real go, but the breaks did not go our way. It was defeat with honour." Second-half bookings were collected by Tranmere skipper Sean Connelly and Swansea's Robinson.
Concluded Little: "A good cup run is something everybody hopes for. Getting to the quarter-finals is a great achievement.
"Some of our best form has come in this competition. Now we are looking forward to having a go at one of the top clubs in the last eight.
"The revenue gained will not do the club any harm at all." Youngster Steve Jennings found the going tough for the Merseysiders and it was no surprise when he was taken off at half time.
Taylor, who was again lethal from the penalty spot, with his fifth goal of the season, was again in commanding form and Dadi was always a menace up front although he found it tough going at times against the solid defensive work of Tate and Iriekpen.
Swansea rang the changes in the last 30 minutes as they tried to force a replay, but Tranmere were in no mood to concede a late equaliser, although they did live dangerously at times.
Man of the match: Iain Hume - Always looked dangerous when Rovers went forward and won the game with a stunning strike.