Marc Goodfellow's injury-time winner got Stoke out of jail as third division Rochdale looked set to spring a shock.
The 21-year-old had the simple task of rolling the ball into an empty net after City substitute Kris Commons had fired against a post.
It was tough on the underdogs, who were the better side in the second half and pushed in vain for a winner after Kevin Townson's 76th minute equaliser The opening exchanges were low key in the extreme before Chris Iwelumo gave the contest a much-needed shot in the arm in the 13th minute.
Iwelumo headed home the first chance of the game at the far post, squeezing his effort past Matthew Gilks from a Wayne Thomas cross.
The visitors tried to hit back as Chris Shuker, on loan from Manchester City, failed to hit the target twice with Michael Simpkins supplying the ammunition on both occasions.
But Iwelumo was within inches of giving Stoke a commanding advantage when his 32nd minute back header from John Eustace's delivery struck the woodwork.
Sean McClare was booked for a late challenge on Goodfellow with the visitors showing more bite as half time approached.
Eustace chipped a 25-yard effort against the bar as the Potters sought a killer blow early in the second half.
But Rochdale rode the storm before twice going close to an equaliser through half-time substitute Townson.
Ed de Goey came to City's rescue with smart saves, but was left helpless when Townson made it third time lucky 14 minutes from time.
Ex-Stoke striker Paul Connor crossed from the left and Townson stooped to head home from five yards.
It was nearly all Rochdale after that before Goodfellow had the final say in a 92nd minute breakaway.