Birthday boy James Milner grabbed both goals as Aston Villa reached the fourth round of the FA Cup for only the second time in eight seasons courtesy of a 2-1 win - but they were given a scare by Gillingham.
Milner netted the winner from the penalty spot 13 minutes from time after Adam Miller was adjudged to have fouled Ashley Young in the box.
Until then, it had looked like the Gills would earn a deserved - and lucrative - replay after Simeon Jackson blasted in his 12th of the season to cancel out Milner's well-taken opener.
The home side started well but were stunned in the 13th minute when Milner netted. The winger - who had not scored for Villa since a brace in the 8-3 Carling Cup win over Wycombe three years ago - took advantage of some hesitation from Miller to dispossess the Gills captain 25 yards from goal.
He played a neat one-two with Stiliyan Petrov and curled a fine strike past Simon Royce from the edge of the area.
Gillingham manager Mark Stimson had admitted he feared a thrashing before the game, but any fears that the Gills would cave in were soon forgotten as they dominated the rest of the first half.
But Villa, who had been on the back foot since their goal, should have doubled their lead five minutes before half-time when Milner crossed for the unmarked Nathan Delfouneso but he volleyed high and wide from eight yards.
The Gills stunned their Premier League opponents by drawing level 12 minutes into the second half. The goal came when Royce's long kick was flicked on by Gary Mulligan and Jackson blasted home his 12th goal of the season.
But Villa regained the lead again 13 minutes from time. Ashley Young, who endured a frustrating afternoon, broke into the box and went to ground under a challenge from Miller and the referee pointed to the spot despite the home side's protests.
After a short delay while a new ball was brought on to the pitch, Milner stepped up and drilled his kick into the bottom left corner.
Copyright (c) PA Sport 2009, All Rights Reserved.