Stan Wawrinka admitted he was a nervous wreck in the locker room before the U.S. Open men’s final against Novak Djokovic. He said he developed cramps as early as the second set, but was told by his coach, Magnus Norman, to show nothing.

But Swiss Maestro Lite showed plenty at Arthur Ashe Stadium. Wawrinka rallied to beat Djokovic and his bloody toe as Flushing fell in love with another Swiss tennis star.

Wawrinka wore down the Serbian baseline machine with powerful groundstrokes to steamroll to his first Open title, posting a 6-7, 6-4, 7-5, 6-3 victory in a nearly four-hour classic Sunday night.

The crowd of 25,051 relished the spectacularly long rallies and rooted madly for Wawrinka, who had been overshadowed for years by his buddy and countryman Roger Federer. Federer sat out the Open to rehab a surgically repaired knee, but texted Wawrinka congratulatory missives and “good lucks’’ throughout the tournament. Federer was said to have watched the match in Switzerland.

“I was really nervous like never before,’’ Wawrinka said. “I was shaking in the locker [room]. When we start five minutes before the match talking the last few things with Magnus, I start to cry. I was completely shaking.”

He showed few of those jitters after the first set and the third-seeded Wawrinka is not only an Open champion, but currently the most dangerous player in Switzerland.

“You deserved it today,’’ Djokovic said on the court. “You were a more courageous player, tougher player, tougher mentally … He deserves to be in the mix, no doubt.’’

Modesty bathed Wawrinka, 31, after his third Grand Slam singles title in his first Open final.

“I’m really far from them,’’ Wawrinka said. “I’m not there.’’

All three of his Slam titles came by beating Djokovic along the way, including two in the finals.

The damning stat for Djokovic, the game’s best returner, was going just 3 of 17 on break points.

“I didn’t capitalize on my opportunities,’’ he said. “I had plenty of them.’’

The hubbub surrounded Djokovic’s injured toenail that needed a medical timeout, but Wawrinka hid his own ailments.

“I was feeling tired already at the beginning of the match,’’ Wawrinka said. “I was feeling the cramp coming in the third set. In the fourth set I had some pain, but most important was what was clear with Magnus before was not to show anything.”

After dropping the first set in a tiebreaker, Wawrinka rallied to win the final three, his deep, one-handed backhand and flat, piercing forehand keeping Djokovic’s on his toes. Djokovic ultimately struggled to move at all in the final set as he said a toenail ripped off, turning it into a bloody mess.

Djokovic defended taking a medical timeout — for more than six minutes — down a break at 3-1 in the fourth set. The trainer retaped Djokovic’s bloody toe and Wawrinka was angry, feeling this wasn’t a serious-enough injury to delay the match. They exchanged words, with Djokovic finally apologizing during the timeout. Djokovic then took another medical timeout during a changeover, trailing 5-2.

Djokovic played down the injury afterward. In the second game of the fourth set, Djokovic looked hobbled, hunching over and touching his left shoe.

“It was quite painful to move around,’’ Djokovic said. “He deserved to win this trophy. I don’t want to talk [more] about this [because] you guys think I’m finding excuses.’

Djokovic entered the match an astounding 51-0 in his career after winning the first set at the Open — an unbeaten streak that crashed.

Djokovic, who won 2016’s first two majors, stayed stuck on 12 Grand Slam titles, making his chase to catch Federer’s 17 more arduous at age 29.

“There’s a lot to learn,’’ Djokovic said. “Life is a big lesson.’’