Nathaniel Mendez-Laing and Greg Halford both scored against their former club as Pompey fell at the first hurdle in the Carabao Cup.
But they took the lead against their Championship hosts when Sean Morrison sent the ball into his own.
Mendez-Laing levelled early in the second half before Halford struck late in extra-time to send the Welsh side through.
Kenny Jackett made three changes from the side that beat Rochdale in the league at the weekend.
One of those was enforced, with Brandon Haunstrup replacing the injured Tareiq Holmes-Dennis at left-back.
The others saw Kal Naismith come in for Conor Chaplin up front, while Carl Baker made way for Adam May in midfield.
There were a couple of familiar faces in the hosts’ line-up, with former Pompey players Brian Murphy and Halford both starting.
It was a cagey start to proceedings, although a few deliveries from Cardiff’s right forced the Blues back-line into action.
One from Danny Ward was headed clear by Jack Whatmough, while another by Matthew Kennedy had to be dealt with by Christian Burgess.
Kyle Bennett saw a shot from outside the box fly narrowly past the post, while Luke McGee was confidently off his line to claim another Kennedy delivery.
But it was otherwise a pretty cagey opening to proceedings on a damp and chilly evening in South Wales.
Stuart O’Keefe sent a header straight into McGee’s arms on 31 minutes before a Cardiff player finally did find the back of the net moments later.
But MORRISON will not have celebrated breaking the deadlock, as he inadvertently turned Naismith’s low cross past his own keeper.
And Murphy was then booked just before the break for pushing down Gareth Evans after the winger had beaten him to the ball.
Cardiff City 0
The hosts, unsurprisingly, came out all guns blazing after the interval and McGee did well to tip Bruno Ecuele Manga’s header onto the crossbar.
But it was only a brief respite for the Blues, as former Fratton loanee Mendez-Laing – who had only just come off the bench – steered home after Lee Tomlin’s ball had been deflected into his path.
It was certainly not all one-way traffic, however, and Murphy got down to his right to stop Bennett from squeezing a shot inside the post.
Jackett made a change to his forward line on 65 minutes, as Naismith made way for Nicke Kabamba – much to the delight of the 851 travelling fans, who were quick to serenade the striker.
But it was Cardiff who were next to go close following Tomlin’s quick break and a deflected drive from Mendez-Laing was well held by McGee.
And the keeper was then quickly off his line to deny Kennedy after some clever trickery from Mendez-Laing had sent the winger through on goal.
It was the hosts who looked more threatening as the seconds ticked down, with Kennedy heading wide before Danny Rose chucked himself in the path Loic Damour’s strike.
The Blues were not done yet, though, and Murphy had to palm Evans’ drilled shot behind for a corner on 84 minutes.
But neither side was able to find a late winner and referee Stephen Martin’s whistle signalled an additional 30 minutes.
After 90 Minutes: Cardiff 1 Pompey 1
Mendez-Laing continued to look dangerous in extra-time, but sent two efforts wide after good work to find space.
And Drew Talbot then took the sting out of Junior Hoillet’s drive to allow McGee a relatively comfortable save.
Blues fans saw a ‘first’ on 102 minutes, when Cardiff brought on Joe Ralls to take advantage of a new rule that allows a fourth substitution to be made in extra-time
The visitors had to soak up plenty of pressure as the Championship side tried to forge ahead before the interval.
But it was Pompey who had a chance immediately after it, with Carl Baker sending a low ball across the face of goal that none of his team-mates could quite connect with.
Cardiff were dominating possession, however, and finally made their dominance count with a winning goal on 113 minutes.
It was Halford who slotted the ball home following a Hoillet corner, but the defender’s celebrations were muted against his former club.
Chaplin immediately came on to try to find a leveller and take the tie to penalties, but Pompey could not find a way through.
Cardiff (4-4-2): Murphy; Halford, Morrison (c), Ecuele Manga, Richards; Pilkington (Mendez-Laing 46), O’Keefe, Damour (Ralls 102), Kennedy (Hoillet 87); Ward, Tomin (Meite 97)
Goals: Mendez-Laing 48, Halford 113
Subs not used: Etheridge, Peltier, Coxe
Pompey (4-2-3-1): McGee; Talbot, Burgess, Whatmough, Haunstrup (Close 106); Rose, May; Evans, Pitman (c) (Chaplin 114), Bennett (Baker 98); Naismith (Kabamba 65)
Goals: Morrison 32 (og)
Subs not used: Bass, Davies, Main
Referee: Stephen Martin