Former world number one Murray, who appeared on the brink of retirement after losing in the first round of the Australian Open in January, battled back from a set and a break down to win 3-6 6-4 6-4.
In the first final between the pair for 11 years it was 34-year-old Wawrinka, who has also suffered injury problems, who appeared on course for victory when he had points for a double break in the second set, having powered through the first.
But Murray, 32, who opted to have hip re-surfacing surgery after the Australian Open and only returned to court in June, initially in doubles, displayed his old fighting qualities and no sign of any physical problems as he roared back to claim a 46th career title.
The deciding set was littered with service breaks but Murray crucially saved break points at 4-4 and then pounced when Wawrinka served in the next game, sealing the title as his tiring Swiss opponent blazed a forehand wide.
"It's amazing to be back playing against Stan in a final like that, he was playing unbelievable," Murray, who appeared close to tears at the end, said on court.
"I never expected to be in this position so I'm very happy. Stan was hitting winners from everywhere but I managed to hang in there. This is one of my biggest wins after everything."
Murray's last title came in Dubai in March 2017 when he was still the top-ranked player in the world.
The Scot is attempting to defy conventional wisdom as no player has ever returned from such a hip procedure to the top levels in singles. He has been picking up encouraging victories of late and reached the quarter-finals of the China Open but Wawrinka was by far his biggest win since returning.
Wawrinka, who had knee surgery two years ago, broke Murray's serve in the second game of the match and dominated many of the rallies with his backhand punching holes in Murray's guard.
Two backhand winners gave Wawrinka a break for 2-1 in the second set and he then had Murray 15-40 down at 1-3.
Murray survived through and became increasingly fired-up as Wawrinka's serve began to cool off.
He broke back, then saved a break point at 4-4 when he challenged an "out" call on a forehand before winning the replayed point and letting out a huge roar.
Two rasping backhands secured Murray the set on Wawrinka's serve and the decider was a real scrap between the old warriors.
Murray had more in the tank though as he took his career record over Wawrinka to 12-8.
The Scot is about to become a father for the third time and joked that his family has grown since his enforced time away from the match court.
"I've got a third one coming so I will have three kids under four years old," Murray said.
"When I have been off Tour my family has got bigger so I need to get back on the road so we don't get out of control."
(Reporting by Martyn Herman, editing by Clare Lovell and Pritha Sarkar)