The eighth seed roared through the first two sets and overcame the distraction of a back injury to Nadal, and then the loss of the third set, to take it 6-3, 6-2, 3-6, 6-3 in two hours 21 minutes.
Nadal, who was chasing his 14th major title, looked as if might pull out with the back injury but he fought back to take the third set and force the match into a fourth set.
It was a stunning win for Wawrinka, who had not beaten Nadal in their previous 12 matches as he rallied to win the fourth set and take the championship.
Wawrinka began nervelessly and after holding his opening two service games for the loss of only two points he made the first move in the final, breaking Nadal in the fourth game.
The Spaniard played a poor drop-shot which was followed by a double-fault to open the door for Wawrinka.
The Swiss again had a break point in Nadal's next service game as he held his own serves without undue pressure.
But he was three break points down serving out for his first ever set against Nadal, only to win the next five points with some magnificent serves to go one set up in 37 minutes.
Fresh from his psychological breakthrough, Wawrinka broke Nadal to love in the opening game of the second with with a cracking backhand return winner.
The Swiss was in the zone, reeling off 12 consecutive points against the non-plussed Nadal, who received a time violation warning for slow play between points.
Nadal's problems mounted when he grabbed his back after playing a forehand. He called for the trainer at the next changeover and went off the court for a medical timeout at 2-1 in the second set.
Wawrinka argued with the chair umpire about why he wasn't told what Nadal's injury was, as the crowd became restless with the Spaniard's seven-minute absence off the court.
When Nadal re-emerged he looked distressed and lost his serve for a third time as Wawrinka charged to a 4-1 lead. The Spaniard sat with his head in hands at the changeover.
Wawrinka served out for the second set as Nadal disconsolately walked to his chair and received further courtside treatment on his back.
However, Nadal fought back and broke Wawrinka's serve for the first time in the final early in the third set.
The treatment or possible painkillers appeared to have some effect and Nadal began hitting the balls with more authority to lead 4-1 as mistakes began to creep into the unsettled Wawrinka's game.
Wawrinka had a couple of break points in the ninth game but Nadal served out for the third set and take the final into a fourth set.
The Swiss again failed to capitalise on two break points early in the fourth as Nadal held serve.
Wawrinka got his fourth break with a big forehand winner to the corner to take a 4-2 lead and move within sight of the championship.
But Nadal broke back after three break points in the next service game with a string of errors from the nervy Wawrinka.
However, Wawrinka broke Nadal again and he served it out authoritatively, winning the title with a forehand.
Nadal became the first man to defeat the top two seeds at a Grand Slam since Sergi Bruguera at the 1993 French Open.
The Spaniard has had injury problems in the past in Melbourne.
He missed the 2006 and 2013 editions through injury, had to retire injured in his quarter-final against Andy Murray in 2010, and in 2011 he was hit by a muscle strain during his quarter-final defeat to David Ferrer.