Substitute Mark Harris sent Cardiff City into the FA Cup fourth round as they edged a match of few chances in the Welsh capital.
Harris fired home with the game looking likely to be resolved by penalties.
Isaak Davies' first Cardiff goal gave them the lead at half-time as he showed pace and composure to cut inside and fire the ball into the net.
However, Ciaron Brown's reckless challenge allowed Daniel Johnson to equalise from the spot on 54 minutes.
A stale game looked destined to be settled by penalties, before Preston over-committed and Cardiff found the winner, with four minutes of extra time remaining, from a four-on-two counter-attack.
Both clubs selected strong sides for this third round clash, played behind-closed-doors due to Covid-19 regulations in Wales, with Cardiff making five changes and Preston four.
It was the Bluebirds who should have taken the lead, but Davies shot wide when clean through.
That chance was a lot easier than the one he gave Cardiff the lead with three minutes before the break. Davies cut in from the left and skipped past his marker before firing home through Daniel Iversen's legs.
Cardiff gifted Preston an equaliser thanks to Brown's rash, sliding tackle on Sean Maguire, with Johnson calmly slotting in the penalty.
Neither side managed another shot on target in a poor second half, but Iversen produced a fabulous save to deny Harris in the first half of the extra period.
Former Cardiff defender Greg Cunningham headed just wide for Preston from a corner with 10 minutes remaining, before the hosts broke clear and Harris hammered home Tom Sang's cross, which was deflected into his path by James Collins.
Cardiff City: Phillips; Brown (Harris, 68), Morrison, Nelson; Ng, Pack (Sang, 100), Vaulks, Colwill (Wintle, 75), Bagan; Davies (Evans, 90), Collins. Subs not used: Ratcliffe, McGuinness, Flint, Sang, Harris, King, Patten.
Preston North End: Iversen; van den Berg, Bauer, Cunningham; Potts, Ledson (Whiteman, 80), Johnson (Browne, 104), McCann (Harrop, 80), Earl; Riis (Sinclair, 58), Maguire (Evans, 93). Subs not used: Hudson, Lindsay, Browne, Storey, Rafferty.
Referee: Mr A Woolmer.