Thomas, who had won only one Tour de France stage in his career on Tuesday, now has three to his name
Geraint Thomas won a dramatic five-man sprint finish to secure back-to-back stage wins at the Tour de France and extend his lead in the yellow jersey.
The Welshman put in a late surge to beat rivals including Team Sky team-mate Chris Froome and Tom Dumoulin after a gruelling climb up Alpe d'Huez.
Froome attacked from the leading group and passed long-time leader Steven Kruijswijk with 3.5km to go.
But he was reeled in before Thomas confirmed he is a serious contender.
The 32-year-old is the first Briton to win on the fabled Alpe D'Huez.
"I am speechless. There wasn't a chance in hell I was going to win today [Thursday]. I just kept following Dumoulin and Froome," said Thomas.
"Can we just go to Paris now?"
- BeSpoke podcast reviews Stage 12: Top of the mountain, top of the world
- 'A bit of respite from the mountains' - Mark Cavendish's guide to stage 13
Italy's Vincenzo Nibali is out of the race after crashing with 4km to go, having apparently tangled with a motorbike, and fracturing a vertebra in his back.
The 33-year-old remounted and eventually finished seventh, 13 seconds behind Thomas, but was forced to quit the race on Thursday night.
Thomas has a lead of one minute 39 seconds over four-time champion Froome, with Dumoulin a further 11 seconds back.
Thomas comes good at altitude
Thomas is the first man to win in yellow on Alpe d'Huez after Lance Armstong's win from 2004 was chalked off
A brutal stage which featured 5,000m of climbing, three hors categorie - the hardest - climbs and a daring breakaway by Dutchman Kruijswijk put strain on the entire field.
But, when he might have been expected to fall back into a support role, Thomas once again proved stronger than team leader Froome.
With four kilometres to go, Thomas led Froome across a gap to cover an attack from Romain Bardet, and was then able to follow Dumoulin as the Dutchman rode back onto Froome's wheel after the champion had launched a significant attack.
And, when the leaders approached the finish as a select group, Thomas' sprint power and know-how, honed by his days on the track where he is a two-time Olympic team pursuit champion, proved decisive over the last 200m.
Despite now leading overall by more than a minute and a half, Thomas insisted that Froome's Grand Tour pedigree means he remains in the service of the defending champion.
"Maybe I can keep the jersey for the next few days," he said.
"This race is so hard and you never know how the body reacts. I am still riding for Froomey, he knows how to ride for three weeks. He is a legend, one of the best ever."
Stage 12 result
1. Geraint Thomas (GB/Team Sky) 5hrs 18mins 37secs
2. Tom Dumoulin (Ned/Team Sunweb) +2secs
3. Romain Bardet (Fra/AG2R La Mondiale) +3secs
4. Chris Froome (GB/Team Sky) same time
5. Mikel Landa (Spa/Movistar Team) +7secs
6. Primož Roglic (Slo/Team LottoNL-Jumbo) +13secs
7. Vincenzo Nibali (Ita/Bahrain-Merida) same time
8. Jakob Fuglsang (Den/Astana) +42secs
9. Nairo Quintana (Col/Movistar) +47secs
10. Steven Kruijswijk (Ned/Team LottoNL-Jumbo) +53secs
General classification after stage 12
1. Geraint Thomas (GB/Team Sky) 49:24:43
2. Chris Froome (GB/Team Sky) +1min 39secs
3. Tom Dumoulin (Ned/Team Sunweb) +1min 50secs
4. Primoz Roglic (Slo/Team LottoNL-Jumbo) +2mins 46secs
5. Romain Bardet (Fra/AG2R) +3mins 7secs
6. Mikel Landa (Spa/Movistar) +3mins 13secs
7. Steven Kruijswijk (Ned/LottoNL-Jumbo) +3mins 43secs
8. Nairo Quintana (Col/Movistar) +4mins 13secs
9. Daniel Martin (Ire/UAE Emirates) +5mins 11secs
10. Jakob Fuglsang (Den/Astana Pro Team) +05mins 45secs