Stoke sealed a 5-2 win in a topsy-turvy game at Huddersfield to move out of the Championship relegation places.
Michael O'Neill's side had led 1-0 before trailing 2-1, only to come from behind themselves as they moved up to 21st in the table.
Tyrese Campbell's brace added to goals from Sam Vokes, Nick Powell and Lee Gregory – with Town's strikes coming from Steve Mounie and a Danny Batth own goal – to seal a first Stoke win in Huddersfield since 1992.
City started the brighter and were celebrating an opener on 15 minutes, but had more than a little help from Huddersfield's defence.
A long ball should have been comfortably dealt with by Danny Simpson but the full-back fluffed his lines and that gifted the ball to Powell inside the box.
Powell then easily teed up Vokes for a simple tap-in from a few yards out.
Town goalkeeper Kamil Grabara then had to be alert to keep out a header from Vokes at the back-post.
Vokes was proving a real menace and was slipped in again just after, only for home defender Christopher Schindler to get in a timely block.
Powell blasted over from distance before Campbell diverted a shot that skimmed the home crossbar in the final action of the first half.
After a first 45 minutes which failed to see them register a shot, Town came out with plenty of purpose after the restart.
And that quickfire start soon saw them go 2-1 up in the space of just two minutes.
First, Mounie rose highest to thump home a header from a corner.
Barely two minutes later they found themselves in front.
A free-kick from Juninho Bacuna was punched weakly by Jack Butland and it ricocheted on to defender Batth before trickling into the net.
Many teams could have wilted after seeing a lead quickly evaporate but Stoke recovered to take back full control of the contest.
Campbell dashed down the right flank and teed up Powell who coolly slid home the visitors' second goal of the afternoon from inside the box.
And it was not long before City were back in front thanks to a well-taken goal from Campbell.
Grabara came and punched away a free-kick but it fell to Campbell who neatly controlled before applying a fine lobbed finish to make it 3-2.
Huddersfield were clearly rattled and they soon found themselves 4-2 down just a few minutes later.
The goal was scored by Campbell but owed much to the determination of Vokes, who beat Jon Stankovic to a header and laid the ball off to his strike partner who produced a classy finish for his second of the day.
Town kept going but they were hit with a sucker punch in the final minute when sub Lee Gregory added a classy fifth.