Neil Warnock had to have words with his side at half time after Sean Morrison's o.g. saw the home side a goal down.
Whatever was said made the difference as City came level to take the game to extra time before getting a winning goal from Greg Halford.
"I thought we started the game well but then we were sloppy until half-time," said Warnock.
"We had to say a few words at half-time, you could say it was a bit harsh.
"But in the second half, and in extra-time, I thought we were super.
"I was pleased with us fitness-wise and we created some good chances.
"Our attitude was good and we changed a few things.
"We pushed Tommo (Lee Tomlin) a bit further central in the second half and it worked well," said Warnock.
"It's been another good session, Tommo got more time as did one or two of the others.
"We persevered and I was delighted really."
Pompey boss Kenny Jackett acknowledged his side were beaten by the better team
‘I felt we gave Cardiff some problems.
‘We played good football at times, particularly early in the game in the first half. There were some good moves, better than Saturday, which I was pleased with.
‘In the end they kept at it and kept at it, got on top of us, we blocked and battled and defended our own box very, very well.
‘There were a couple of great saves by the goalkeeper (Luke McGee) and in the end they just had a little bit too much for us, particularly from the bench with the widemen coming on.
‘We just couldn’t quite hold out. I felt we showed fantastic character and attitude and when we needed to hang in and defend we did that as well.
‘There are times you need to do that and try to aspire to more. But in the end Cardiff had a bit too much.’