It was the 16th-seeded American's third title of the year, fourth overall, and first at a Masters. It sends him through to the finals in London for the first time. He will break into the top 10, climbing to ninth.
"Incredible week. Hard to describe, honestly. I don't think it's really hit or soaked in yet,'' said Sock, who was one game away from losing in the second round. "To come back from the deficit I was down and to have this trophy next to me now has been an incredible achievement.''
He sealed victory on his first match point when Krajinovic, a Serbian qualifier ranked No. 77, sent a backhand long. Sock fell onto his back with his hands on his face, then jumped into the seating area to celebrate with his team.
"I had some anxious sleep last night,'' Sock said. "I was able to find that groove in the second and third [sets] and kind of turn things around.''
He is the first American winner here since Andre Agassi in 1999 and the first American winner of a Masters tournament since Andy Roddick at Miami in 2010.
"I've had a rough season pretty much since, since March,'' Sock said. "Coming in this week I had no idea I could even make London. It wasn't in my head. I just wanted to play some good tennis my last week and go start my offseason.''
With a wry smile, Sock said he would be celebrating the biggest win of his career with "just a water on the rocks.''
Krajinovic, 25, was the first qualifier in a Masters final since Jerzy Janowicz, also here, in 2012.
After losing, the Serb sat slumped in his chair, shaking his head in disappointment.
He had only played finals on the challenger circuit before, winning all five of them, and came through the qualifying rounds. He seemed to run out of energy in the third set, which Sock controlled completely.
"I was not aggressive enough. I have to be against him,'' Krajinovic said. "He started to play better and better, and I didn't serve well.''
Still, he will climb to No. 33 next week.
"It's an amazing week, with a lot of good wins. From [qualifying], I beat so many good guys, better ranking than me,'' he said. "So it's all positive coming home, finally having holidays after playing so many matches this year.''
The first set was even, with Krajinovic looking a little sharper than Sock, who is also 25.
Sock was 30-40 down in the 12th game, and Krajinovic had his first set point. He took it when Sock went for a typical cross-court winner on forehand and whipped his shot into the net.
He responded well, upping his level in the second set as the momentum started to turn.
"I lost energy,'' Krajinovic said. "But it was a great week for me. Well done to him.''
Sock secured a crucial break in the third game of the decider with a superb forehand winner on the run, and then held for 3-1.
By this stage, Krajinovic was reeling and dropped his next service game when Sock hit a backhand crosscourt winner that flew past Krajinovic's outstretched racket. He was broken again when he served to stay in the match.
Sock had nine aces and broke Krajinovic's serve six times to compensate for the three times he dropped his.
His other titles this year were at Delray Beach, Florida, and Auckland, New Zealand -- both on outdoor hard courts.
This one gives him a considerably bigger winner's check of 853,430 euros -- almost $1 million -- and a ticket to London.
"It's a good Sunday for sure,'' Sock said. "The only thing that would make it better would be if the Kansas City Chiefs win as well back home, my favorite NFL team.''