"I had half a second to react. My bars were going to hit them or my shoulder. I managed to just get my handlebars out of harm's way."
Team Sky rider Chris Froome leads the overall race by 16 seconds from compatriot Adam Yates.
Two-time champion Alberto Contador pulled out with a fever midway through the stage.
Among those who couldn't keep up with Froome on the final climb were French favourite Romain Bardet, top American hope Tejay van Garderen and Fabio Aru of Italy.
"That was a tough stage and the weather made it even tougher," Froome said. "One minute we were pouring water over our heads and ice packs down our backs and the next minute there was ice falling from the sky.
"We were just trying to ride face down so the hail didn't hit our faces," added Froome, who took the yellow jersey with a downhill attack and stage win a day earlier. "It was pretty difficult out there."
Listen: Kiwi rider George Bennett talks to Radio Sport's Elliott Smith
Part of an early breakaway, Dumoulin attacked with 12 kilometers remaining in the 184.5-kilometre leg from Vielha d'Aran, Spain, to Arcalis in the principality of Andorra.
"A few days ago if you said I would win maybe the hardest day in the whole Tour de France this year, I would say you were crazy," said Dumoulin, who was sick last week. "But sometimes it all comes together and the legs were feeling good today.
"I'm a time trialist so if I have a gap it's difficult to close it on me," Dumoulin added.
Radio Sport/AP