Elliott List smashed home a late winner as Gillingham produced an FA Cup third-round shock by dumping out Cardiff City. The midfielder buried his finish past Alex Smithies with nine minutes remaining at Priestfield to upset the Premier League visitors.

Cardiff had been the better side but were unable to make a breakthrough against the League One strugglers, twice hitting the woodwork in the second half and squandering numerous other chances.

Nathaniel Mendez-Laing went closest for the visitors when he curled a shot against the crossbar 20 minutes from time, while the Gillingham defender Gabriel Zakuani earlier diverted the ball against his own goalkeeper’s post.

With top-flight survival the priority for Cardiff it looked as if they would have to be content with an unwanted replay in south Wales before List emphatically intervened.

Neil Warnock, who before the tie urged his Cardiff players to avoid becoming a Cup headline, was left frustrated by the profligacy of his team and claimed they “would not have scored in a million years”.

With next weekend’s crunch relegation clash with Huddersfield looming it was no surprise that Warnock made seven changes from the side that lost 3-0 to Tottenham. Gillingham made only one enforced change due to an injury to Billy Bingham and it was his replacement, List, who had the first opportunity, turning in space to fire an effort that was comfortably gathered by Smithies.

The visitors then began to control proceedings and should have been ahead after 16 minutes. A superb crossfield pass from Mendez-Laing found the left-back, Joe Bennett, in space inside the penalty area but his close-range effort was repelled by the Gillingham keeper, Tomas Holy, before Joe Ralls’s goal-bound follow-up was blocked by Alex Lacey. The one-way traffic continued with Sean Morrison then denied by an excellent save from Holy after a Ralls corner.

But Warnock’s men, for all of their dominance, were given a warning minutes before the break. The full-back Bradley Garmston produced an inviting cross from the left and the unmarked Tom Eaves – his side’s top scorer, searching for his 16th goal of the season – headed narrowly over the bar.

Gillingham, a point above the relegation zone in League One and coming into this game on the back of successive defeats, remained a threat in the second half. They should have broken the deadlock in the 58th minute but Josh Parker somehow fired over from close range at the near post following Luke O’Neill’s dangerous delivery from the right.

Cardiff then almost went ahead in fortunate fashion when the ball ricocheted off Zakuani and struck the upright following pressure from the City substitute Josh Murphy. Mendez-Laing later worked space but fired wide and then rattled the frame of the goal from the edge of the box.

The away side, finalists in this competition in 2008, were made to pay for their profligacy with nine minutes left when List made the most of Eaves’ ball to find the net from 15 yards.

The margin of victory could have been greater – Callum Reilly struck the bar in stoppage time – but Gillingham hung on to progress to the fourth round for the first time in 15 years. Steve Lovell specified List as deserving of praise, along with Eaves, and paid tribute to the supporters. “The crowd were excellent,” the Gillingham manager said. “They were noisy and got right behind us.”

Cardiff’s defeat was compounded by second-half injuries to Kadeem Harris and Danny Ward. The former received lengthy treatment on the pitch for a shoulder problem and Warnock was unhappy about the time it took for the medics to arrive.

“I think if you’re a medical person and you are wanting a stretcher, you’d be there quicker. If he’d had a heart attack, he’d be dead now,” he said. “I think they’ve got a lot to learn.”