Greg Halford’s venomous extra-time strike against battling Portsmouth sent Cardiff City into the EFL Cup second-round draw.
The visitors from League One led after home captain Sean Morrison directed Kal Naismith’s cross into his own net.
After coming on at the start of the second half, winger Nathaniel Mendez-Laing levelled with his first touch.
Mendez-Laing came close to winning the tie for City in normal time before Halford finally sent them through.
The visitors, under new ownership in former Walt Disney chief executive Michael Eisner, were hopeful of a fairytale outcome after taking the lead.
The League One side’s confidence grew as the opening period wore on.
But Bluebirds’ summer signing Mendez-Laing’s equaliser shifted the momentum back to the hosts.
The first half of extra-time was also scoreless and the game seemed to be heading for penalties until Halford scored in the 113th minute against his former club.
It was Halford’s first goal since the opening round of the same competition in 2016 as he made the most of Junior Hoilett’s build-up.