Brentford were leading the League Two strugglers through England hopeful Toney's early goal, but then sat back and allowed their opponents to come at them in the second half.
The Gills duly hauled themselves back into the match when Mikael Mandron's late header secured a 1-1 draw.
Toney did at least have the chance to showcase his nerveless penalty technique in the shoot-out one last time before Gareth Southgate names his squad by tucking in his side's first.
But after 11 successful spot-kicks Mikkel Damsgaard crashed his against the crossbar to give Gillingham an unlikely win and a place in round four.
Toney's goal came after only three minutes and was probably the simplest of his nine so far this season. The 26-year-old had endured a tough few days, having been suspended at Nottingham Forest on Saturday before it emerged that he is the subject of a Football Association probe into an alleged historic breach of betting rules.
Such is his desperation to be at the World Cup, having been in Southgate's last squad without getting on the pitch, that Bees boss Thomas Frank picked him to face Gillingham to help him “fight for his position”.
In fact, Frank named a surprisingly strong side, making six changes with two of them being Toney and Denmark midfielder Christian Norgaard, back after 10 weeks out injured.
Kick-off had been delayed by 20 minutes due to Gillingham falling foul of the west London traffic, but Toney did not waste any time in finding the net.
League Two side Gillingham have KNOCKED OUT Brentford on pens! 😮 pic.twitter.com/1I8l6iB6MW
— Sky Sports Football (@SkyFootball) November 8, 2022
The defences in Qatar are not likely to be as accommodating as Gillingham's, who let Damsgaard bring down David Raya's clearance, wander through the centre and tee up Toney, who finished into an empty net. Then as half-time approached Saman Ghoddos planted a looping header against the woodwork.
Toney should have doubled the lead when he was found in the area by Josh Dasilva but he lashed his shot across goal and narrowly wide.
Then, in the 73rd minute, Gillingham equalised from out of nowhere with their only effort on target. Alex MacDonald had an instant impact off the bench with the inviting cross which was headed in by fellow substitute Mandron.
Goalkeeper Jake Turner kept Gillingham on course for a shoot-out with a stunning save to keep out Ethan Pinnock's 89th-minute header, and when Damsgaard's spot-kick came back off the crossbar they celebrated a famous win.
Additional reporting by PA.