Everton saw a two-goal lead vanish before they scraped through their Carling Cup visit to Bristol City 4-3 on penalties.
The League One side stormed back after looking out of the tie at the break, as in a three-minute burst, Alan Stubbs put through his own goal and then teenager Leroy Lita brought City level with a sensational finish.
On both occasions the Merseyside club had been opened up down the right and manager David Moyes had to take emergency action, pulling off Gary Naysmith and restoring Alessandro Pistone to left-back.
After eyeing their opponents, who stand 50 or more places beneath them in the pyramid, Moyes decided to rest half his first team.
This proved to be a doubtful strategy once City hit their stride.
Referee Phil Crossley gave Everton a penalty on the half hour which looked doubtful, a shot from Leon Osman appearing to hit the defender's hand.
Duncan Ferguson took the penalty to score his first goal this season and then, right on the break, Nick Chadwick, who had come on for Osman, headed the second goal.
Stubbs was debited with an own goal as he and Christian Roberts lunged at Scott Murray's cross and three minutes later it was Roberts, this time on the wing, who provided a cross for teenager Lita to register his eighth goal of the season.
City raised their game to match their goals, but Everton had a late chance to go back in front with a second penalty. This time there was no doubt about it, James McFadden clearly brought down by full-back Jamie Smith.
McFadden, still looking for his first goal after a year with Everton, saw his fierce straight shot parried by keeper Steve Phillips, who then brilliantly turned the follow-up over his bar.
Phillips then made several excellent saved to deny Everton as the tie headed for extra-time.
The penalty shootout saw the Merseysiders triumph as Lee Carsley hit the vital tenth penalty to put Everton through 4-3 and they will be home to Leicester City or Preston North End in the third round.