Novak Djokovic’s mastery came to a stunning and abrupt halt Sunday night.

A painful shoulder injury and Grand Slam nemesis were too much to overcome.

Down two sets and a break, the defending U.S. Open champion and No. 1 seed shook his head as he approached the chair umpire, informing the official he couldn’t go on. Djokovic’s aching left shoulder forced him to retire in the third set, initially drawing boos from the crowd and snapping his string of 36 Grand Slam singles victories in 37 matches, along with four of the past five major titles.

“You just know when you know,” the 16-time Grand Slam champion said after his fourth-round exit to No. 23 Stan Wawrinka, 6-4, 7-5, 2-1, at Arthur Ashe Stadium on Sunday night. “When you feel like you’re not able to hit the shot anymore.”

“It’s never the way you want to finish the match,” added Wawrinka, who will face fifth-seeded Daniil Medvedev in the quarterfinals. “I feel sorry for Novak.”

Djokovic, 32, was bothered by his shoulder in the second round on Wednesday, twice being attended to by a trainer. After the victory, he said he had been playing with pain and was “lucky” to advance. But in the third round, after not practicing the day before and performing well, Djokovic said the shoulder felt much better.

It was clear, however, he wasn’t playing at his usual world-class level against Wawrinka, notching just two aces, losing his serve four times, committing five double faults and a stunning 35 unforced errors. Djokovic uncharacteristically struggled to keep up with the 34-year-old Swiss veteran from the baseline and his elite return game was nowhere to be found.

“I’m sorry for the crowd,” said Djokovic, who remains — for now — four Grand Slam titles shy of Roger Federer’s record 20. “Obviously they came to see a full match, and [it] just wasn’t meant to be. I mean, a lot of people didn’t know what’s happening, so you cannot blame them.”

He declined to offer much insight into the exact status of the shoulder, other than to say he’s been getting treatment for “constant pain” for weeks. There are days, he said, it brings him more discomfort than others. Sometimes, pain-killers work. Sunday was clearly not one of those days.

“It is frustrating, very frustrating,” he said. “Obviously [I’m] not the first, not the last player to get injured and withdraw from one of the biggest events in sports. But obviously I just came off the court, so of course it hurts.”

Djokovic didn’t want to take away from Wawrinka’s victory, crediting him for his high level of play. Wawrinka has now defeated him in their last four grand slam meetings, including the 2016 Open final. Since that victory, his third major victory, his career has gone awry. He needed knee surgery in 2017 and fell all the way to 263rd in the world the next year. But he reached the quarterfinals at the French Open this year, has climbed back into the top 25 and looks like a contender in Queens, having dropped just two sets through four matches.

“It’s been really tough since my surgery. It took me two years now to be back at that level,” Wawrinka said after his fifth win over a No. 1-ranked player, which is tied for second-most in history, along with Boris Becker.

Djokovic’s exit could lead to the first meeting between Federer and Rafael Nadal in Flushing, granted they both reach the final. They are five wins away, two by Federer and three by Nadal, from what would be a mega-showdown Sunday afternoon. Djokovic wouldn’t count out Wawrinka, though.

“He loves to play on the big stage against the best players of the world. It’s what got him three slams and Olympic gold and everything,” Djokovic said. “It’s great to see him playing on the highest level.”