In front of the watching Sean Connery, ninth seed Wawrinka broke in the first set after a long and tense final game to clinch it 6-4.
He then took the next two 6-3, 6-2 to end Murray's triumphal run.
The Scot had not been entirely convincing in his first four matches at the US Open, while Wawrinka went into the clash full of confidence after knocking out Tomas Berdych.
The Swiss is back in the top 10 for the first time in four years and playing the best tennis of his career.
Murray had won eight of their previous 13 matches but Wawrinka is a player who has given him trouble, not least in their last meeting in New York three years ago.
The Scot lost to Wawrinka in the third round on that occasion - the last time he has failed to reach the quarter-finals in any grand slam he has played.
Murray has started matches particularly nervously this tournament but he looked more relaxed here, playing two fine lobs in the opening game.
Wawrinka was the aggressor, though, his one-handed backhand working well, and he gave Murray a tough game before he eventually held for 2-2.
The Swiss had the embarrassment of beginning the seventh game with an air shot, but generally he was holding serve relatively comfortably.
And it was Wawrinka who had the first chance when Murray netted a forehand to give up a set point at 4-5.
He saved that one with a big serve but he was far from out of trouble.
Murray saved four more set points but on the six chance he hit a forehand long and earned a code violation for smashing his racket on the court.
It was the second successive match in which he had dropped the opening set, but Wawrinka is a much tougher customer than Denis Istomin.
The 28-year-old was in a new position of being the last Swiss player left in the tournament following Roger Federer's demise, and he was relishing it.
Murray was in trouble again at the start of the second set as he let a 40-0 lead slip but he saved a break point with a second-serve ace.
It was slightly ironic given Wawrinka had been all over the Scot's second serve, which was often below 80mph.
Murray has cut an unhappy figure on court most of the tournament and it was no different today, the defending champion searching desperately for his best form.
He has not served particularly well in any of his matches and Wawrinka kept the pressure on.
Murray cracked again in the sixth game, three errors giving his opponent the chance to nail a backhand down the line and move to 4-2.
Murray at least made Wawrinka serve out the set and the Swiss looked a little nervy, but he clinched it 6-3 when the third seed put a return wide.
Wawrinka was in no mood to loosen his grip and kept up the pressure in the third set, breaking an unconvincing Murray twice more to take it 6-2.