Team Sky’s Thomas was racing to third place on the mountaintop finish of the race when a man reached out from behind the security barriers to try and grab him.
The Welshman stayed on his bike to increase his overall lead on Dutch rival Tom Dumoulin (Sunweb) to 1:59, with four-time champion Chris Froome, Thomas’s teammate, in third at 2:31.
If he avoids disaster on the way to the Champs-Élysées in Paris on Sunday, Thomas will make history as the first Welsh winner of the Tour.
But the 32-year-old admitted his bid, which has been hampered by a minority of rowdy fans who have booed and jeered Team Sky on several occasions, could have been ended by an “idiot.”
Pictures on social media show a bearded man wearing an Ag2r La Mondiale shirt apparently reaching out to grab Thomas. But he said it felt more like a “hit.”
“I definitely felt it. It didn’t feel like a grab, but like a hit,” Thomas said prior to the start of stage 18 from Trie-sur-Baise to Pau.
“I was going quite fast past him and it certainly moved me off my line and it was a bit of a shock.
“I think it was too much to drink and a bit of an idiot.”
Thomas added: “We are coming to race our bikes, that’s all we want to do. The whole peloton wants to do it safely. That’s a bit too much.”
Sky sporting director Nicolas Portal, a former rider with the team, appealed to fans to use common sense.
“Just try to think about what you are doing,” Portal said. “Would you do that in the streets in a city? No.
“If he crashed, broke his collarbone, it would have been done and finished just because someone doesn’t like this guy.
“It’s been three weeks with things happening. It’s like we are almost used to it, and that’s bad.”