(CNN) In an era where men's tennis has been dominated by the "Big 3" of Roger Federer, Rafael Nadal and Novak Djokovic , Stan Wawrinka can at times be a forgotten man.

The 34-year-old Swiss has won three major titles -- and they all came against members of the Big 3.

Guess what? He's still here.

On Sunday night in New York, Wawrinka struck again, stunning the world No. 1 and defending US Open champion Djokovic 6-4, 7-5, 2-1 to advance to the quarterfinals. It was a rematch of the 2016 US Open final, which Wawrinka won in four sets.

Djokovic, who has been battling a left shoulder injury, elected to retire in the third set when Wawrinka was leading by a break, eliciting boos from sections of the Arthur Ashe Stadium crowd.

"I'm sorry for the crowd. Obviously they came to see a full match, and just wasn't to be," Djokovic said at his news conference. "I mean, a lot of people didn't know what's happening, so you cannot blame them."

Wawrinka said in his on-court interview: "It's never the way you want to finish a match. I'm really sorry for Novak. He's a good friend. He's an amazing champion.

"We've played some amazing battles all my career. I feel sorry for him. I want to keep my level (from) tonight. I think I was playing super good tennis. I am happy to be back."

With the loss, the Serb, who won the Australian Open and Wimbledon earlier this year for his 15th and 16th major titles, failed to get closer to Nadal's 18 titles and Federer's 20 on the all-time men's list. He had not lost before the quarterfinals in New York since 2006, when he was 19 years old.

"It's no secret that I have, you know, of course desire and a goal to reach the most slams, you know, and reach Roger's record," Djokovic, 32, said. "But at the same time, it's a long road ahead hopefully for me. I hope I can play for many more years. I'm planning to. I mean, I don't see an end behind the corner at all.

"Now it's a matter of keeping my body and mind in shape and trying to still peak at these kind of events that are majors and that are the most significant in our sport."

Wawrinka will face No. 5 Daniil Medvedev in the quarterfinals.

'Evaluation is to come'

Djokovic confirmed to reporters it was the left shoulder, which has been bothering him for a couple of weeks, that forced him to retire.

"Evaluation is to come," Djokovic said. "Obviously I did a lot of different treatments and diagnostics and everything in the last couple weeks. I obviously have to do it again and see how the shoulder reacts."

Djokovic was asked if he would play again this year.

"Obviously, not playing is going to help speed up recovery," he said. "I'm planning to play Tokyo, and hopefully I'll be able to do so."

Wawrinka, meanwhile, underwent two knee surgeries in 2017 and has been working his way back up the rankings since. Currently he's ranked 24th and is the No. 23 seed in the US Open. His career high was No. 3, back in 2014.

"It's been really tough since my surgery," Wawrinka said. "It took me two years now to be back at that level. Last time I entered this court was last year. I wasn't really ready but it's been amazing to be back this year at that level. The atmosphere is always something special to play a night session."

Uncharacteristic errors from the world No. 1

After Wawrinka won the first set, Djokovic raced to a 3-0 second-set lead. But the Swiss put Djokovic through long, hard-hitting rallies, leading to mistakes not normally seen from the world No. 1. After losing the second set, the trainer worked on Djokovic's shoulder.

Once Djokovic double-faulted to give the break to Wawrinka early in the third set, he was done. At the time of his retirement, Djokovic had 35 unforced errors.

"The pain was constant for weeks now," Djokovic said to reporters. "Some days higher; some days with less intensity and obviously taking different stuff to kill the pain instantly. Sometimes it works; sometimes it doesn't. You just know when you know, I guess, when you feel like you're not able to hit the shot anymore."

Wawrinka, meanwhile, won 84% of his first-serve points at 32 of 38 against arguably the best returner in the game.

Wawrinka's record against those who have been ranked No. 1, at 5-21, doesn't initially look impressive. But after an 0-15 start, he's gone 5-6 since, including defeating Andy Murray at the 2017 French Open semifinals; Djokovic at the 2015 French Open final and 2016 US Open final; and against Nadal at the 2014 Australian Open final.

His head-to-head record against Djokovic is now 6-19.

"I was feeling good on the court," Wawrinka said. "I was playing well. The more the match was going, better I was playing, I was hitting really hard the ball. I was feeling great on the court. That's the most important.

"For sure I could see some little thing that (Djokovic) was in trouble. But I was most likely, most of the time, focused on myself because I know how well he can fight. I know how well he can come back. Doesn't matter how he's feeling on the court, and that's what I was focusing on."