Stan Wawrinka won the U.S. Open title on Sunday, beating world No. 1 Novak Djokovic 6-7 (1-7), 6-4, 7-5, 6-3 in an extremely well-played match that was marred by a late injury to Djokovic.

In the fourth set Djokovic began to grimace, and finally took a controversial medical timeout after winning the fourth game. A trainer came out and attended to Djokovic's toe, much to Wawrinka's dismay.

Wawrinka maintained his composure, however, winning the fourth and final set to take home his third career Grand Slam title.

"This is amazing," Wawrinka said after the match. "I came here without expecting to win it, but every time I stepped on the court I was trying to win every match. I think I played quite a lot of tennis these two weeks. I'm completely empty."

Stan Wawrinka beat Novak Djokovic to win the 2016 U.S. Open. USATSI

After a four-set win in the first round, Djokovic had a notoriously easy path to the semifinals due to a walkover and two opponents retiring due to injury.

Djokovic looked like he was going to have another easy match, building a dominant 5-2 lead in the first set. But something clicked for Wawrinka and he came all the way back to force a tiebreak. Though Djokovic won 7-1, Wawrinka had clearly gained back some momentum.

Wawrinka carried it into the second set, which he won 6-4 to even up the match.

The pivotal third set seemed destined for another tiebreak, but Wawrinka continued to fight and managed to break Djokovic in the final game of the set to win, 7-5, and take a 2-1 lead in the match.

In the second game of the fourth set, Djokovic seemed to tweak something in his lower body, and dropped his service game to give Wawrinka a 2-0 lead. Djokovic clearly was not moving well in the third game, and Wawrinka held to take a commanding 3-0 lead. After Djokovic held, he called for medical attention before the fifth game.

After the medical timeout Djokovic looked to be moving much better, but Wawrinka held to take a 4-1 lead and control of the match.

The controversy arose because a medical timeout is supposed to be used for a serious injury, and it appeared that Djokovic was dealing with blisters on his toes. Wawrinka appeared displeased stretching and talking throughout nearly the entire break in play.

Djokovic asked for a second medical timeout when Wawrinka was up 5-2 in the final set.

"After playing seven, eight months of the season, obviously you're not very fresh," Djokovic said after the match. "But of course coming into the Grand Slam final you're giving it your best. ... We both felt the demanding match that we played today, physically."

Djokovic had a walkover in the second round when Jiri Vesely withdrew due to injury before the match. Djokovic's next opponent, Mikhail Youzhny, retired just six games into the match, and he breezed to an easy straight-set victory over Kyle Edmund in the fourth round. His quarterfinal opponent, Jo-Wilfred Tsonga, also retired early. He then had a fairly quick semifinal win over Gael Monfils.

Wawrinka's path was quite the opposite. After three-set victories in the first two round, Wawrinka had to gut out a five-set win over Daniel Evans in the third round. All of the rest of his matches in the tournament, including the final, lasted four sets.

This was the first U.S. Open title for Wawrinka, who won the Australian Open in 2014 and the French Open in 2015.