Van Garderen (BMC), came round the inside of the final corner to edge Mikel Landa (Sky) at the uphill finish of the 137km stage from Moeana to Ortisei.
"(Landa) is a strong sprinter and a great climber," Van Garderen said. "I tried to play it as best I could, but I didn't know I was going to win until I crossed the line."
Thibaut Pinot (FDJ) was third, eight seconds behind the front two, after five categorised climbs through the Dolomites.
Van Garderen was clearly emotional after crossing the line, following a difficult couple of years.
He has had to abandon three of his past four grand tours and came to the Giro hoping to contest overall victory but lost valuable time early on.
"It's been a rough couple of years in grand tours as far as the general classification goes, but I did my best to keep the morale high," he said.
"It's my first grand tour victory, so it's an incredible feeling, especially in an area like this, that I'm so familiar with. I've done a lot of camps here, so I know every inch of road. It feels incredible to get this victory."
Dumoulin took another step toward overall victory with an impressive ride to hold off his main rivals. The Sunweb rider remained 31 seconds ahead of 2014 champion Nairo Quintana (Movistar) with two-time champion Vincenzo Nibali (Bahrain-Merida) third, 1min 12sec behind. Pinot is only 24 seconds off a podium place.
"Nibali and Quintana are only focusing on me, and trying to make me lose instead of trying to win," Dumoulin said.
"I really hope that riding like this they will lose their podium spot in Milan, that would be really nice, and I would be really happy."
Quintana and Nibali knew stage 18 would be their chance to close the gap to Dumoulin. It appeared as if they would do when Quintana attacked on the third climb and Nibali followed him, but Dumoulin paced himself back to them by the summit.
Quintana attacked again with 6.5km to go and opened up a small gap but was once again reeled in by the rest of the title contenders.
Dumoulin attacked several more times as he appeared to almost be toying with his rivals.
"In the last climb, I was feeling strong. So I decided to show them that I'm also awake," Dumoulin added.