Gills will welcome Premier League side to ME7 in FA Cup third round.
Gillingham will play Premier League side West Ham United at MEMS Priestfield Stadium in the third round of the Emirates FA Cup.
The draw was made on BBC Two on Monday evening by Tony Adams and Micah Richards, and it will see the Gills welcome the Hammers to Kent.
Gillingham have so far defeated both Sunderland and Doncaster Rovers to reach this stage and were allocated ball number 56 for the draw.
The club reached the fourth round of last season’s competition, eventually being eliminated by Swansea City.
Manager Steve Evans said: "I wanted West Ham! It's a fantastic club with brilliant supporters and owners who I know well. I have the utmost respect for Manuel Pellegrini, and it will be great to see him again."
Full draw:
Leicester City v Wigan Athletic
Queens Park Rangers v Swansea City
Fulham v Aston Villa
Chelsea v Nottingham Forest
Wolves v Manchester United
Charlton Athletic v West Brom
Rochdale or Boston v Newcastle United
Cardiff City v Forest Green or Carlisle United
Oxford United v Exeter or Hartlepool
Sheffield United v AFC Fylde
Southampton v Huddersfield Town
Liverpool v Everton
Bristol City v Shrewsbury Town
Bournemouth v Luton Town
Brighton v Sheffield Wednesday
Bristol Rovers or Plymouth v Coventry or Ipswich
Eastleigh or Crewe v Barnsley
Manchester City v Port Vale
Middlesbrough v Tottenham
Reading v Blackpool
Watford v Tranmere
Preston v Norwich
Millwall v Newport
Crystal Palace v Derby County
Solihull Moors or Rotherham v Hull
Brentford v Stoke
Fleetwood v Portsmouth
Arsenal v Leeds
Gillingham v West Ham United
Burton v Northampton
Burnley v Peterborough
Birmingham v Blackburn
Ties will be played the weekend of Friday January 3 – Monday January 6.
More details will follow.