The 23-year-old, who had never previously finished in the top five of a downhill World Cup race, finished in a time of two minutes 6.23 seconds, just ahead of Italy's Christof Innerhofer, with Kjetil Jansrud of Norway taking bronze.
Aksel Lund Svindal, Norwegian World Cup leader, was fourth, while American veteran Bode Miller - who dominated two of the three official training runs - trailed in eighth place. He had led by 0.31secs at the second split time, but fell away on the second part of the course.
There was no such disappointment for the Austrians. Not this time. The country's men's ski team had been criticised heavily after failing to win a single medal in Vancouver four years ago but they have improved in form recently- with Hannes Reichelt last month winning the World Cup downhill at Kitzbuhel.
"This year we were criticised quite a bit," said Mayer, whose father, Helmut, won silver in the Super G at the 1988 Calgary Olympics. "Two weeks ago, Hannes won the most important World Cup race on the calendar. Now we have an Olympic medal. We can put the criticism aside.
"I knew if I had a bib number between one and 15, then I had a good chance. It wasn't until I got on the podium I realised I was the Olympic champion. It's unbelievable. I've only dreamed of this."
Miller's bid to win a sixth career Winter Olympic medal floundered on the lower half of a course he had relished in practice, as he trailed in 0.52secs behind the winner. "I'm not really sure what went wrong," he said. "I wanted to ski it as hard as I could and not really back off, but it requires tactics which I didn't apply.
"I feel disappointed. I skied hard and well, and that's the most important thing. It just didn't go all right."
Innerhofer was the closest challenger to Mayer. He was leading by 0.58s at the first split and he maintained his advantage until the lower part of the course, where he was nudged back into silver.
Reigning downhill champion Didier Defago of Switzerland briefly looked like becoming the first man to win two Olympic downhill titles as he led by 0.13s at the second split, before also falling away.
"I woke up this morning and I knew that I could win this race," Mayer added. "I was smiling the whole day, all throughout the inspection. It was my day."