Gillingham 1-3 Stoke
Tony Pulis enjoyed a successful return to Priestfield as his Stoke side survived an early scare to knock a spirited Gillingham out of the FA Cup.
The Gills took the lead when top-scorer Danny Kedwell fired home from a Danny Jackman cross.
But the visitors levelled when Jonathan Walters drilled the ball under goalkeeper Ross Flitney, before Cameron Jerome's volley put Stoke in front.
Defender Robert Huth headed in a third from a Wilson Palacios corner.
The home side rallied and enjoyed plenty of second-half pressure but, for all their effort and tenacity, failed to penetrate the Stoke defence for a second time.
It looked as though an upset might be on the cards when they took a deserved lead early on.
After a lively start from the home side, Jackman was allowed time to cross from the left and Chris Whelpdale flicked on before Kedwell controlled well and fired home from close range for his 11th goal of the season.
A scrappy period ensued and the Premier League side began to come in to the game more, forcing chances from successive corners.
Ryan Shawcross poked a clever backheel just wide before Huth, finding himself in space, headed over.
Stoke were level shortly after the half-hour mark through Walters following a neat interchange with Jerome, but Flitney will feel he should have done better after he allowed the ball to squeeze under his body.
Kenwyne Jones had a golden opportunity to put Stoke in front soon after, heading wide at the far post from a Walters cross when it looked easier to score.
But the away side soon had the lead, Ryan Shotton delivering a long throw-in which Shawcross headed against the crossbar, but the ball bounced kindly for Jerome, who fired a composed volley into the net.
Stoke continued to press after the break and doubled their advantage within five minutes of the re-start through Huth's well-placed downward header.
The visitors could have added to their tally with the impressive Jerome and substitute Ricardo Fuller missing excellent chances late on.
Gillingham were almost rewarded for their second-half pressure when substitute Luke Rooney forced a fine save from Asmir Begovic, but the League Two side were left frustrated.
Pulis, who was criticised by Gills chairman Paul Scally in the matchday programme after a long-running despite between the pair, received a warm reception from the home fans prior to kick-off, which he acknowledged by applauding all sides of the ground.
He will no doubt be happy with the fight and, ultimately, the quality Stoke produced to progress to the fourth round.
Gillingham manager Andy Hessenthaler told BBC Radio Kent:
"The first 35 minutes we were terrific, and then unfortunately for the last 10 minutes of the first half we switched off a couple of times.
"We felt down at half-time but felt we were in the game and at the start of the second half we switched off, they had a free header and you can't do that.
"I'm proud of my players. We're playing against a side who are not at the bottom of the Premier League. Year in, year out they're improving. I know he's made changes but it's a strong squad and you've got to take positives out of that."
Stoke City manager Tony Pulis told BBC Radio Stoke:
"In the first 20 minutes, they came out of the blocks a lot stronger than us and when they scored, it was no surprise.
"After they scored the goal, it seemed to settle us down. We had two great chances before we scored, and then when we scored, from that point onwards I didn't think we were going to lose the game.
"They were important goals and at important times."