Grigor Dimitrov, the world No 78 who came into this year’s US Open amid one of the worst runs of form of a 12-year professional career that hasn’t always lived up to expectations, rallied from two sets to one down to stun an ailing Roger Federer and the Arthur Ashe Stadium crowd squarely behind him in a quarter-final thriller on a muggy Tuesday night.

The Bulgarian came from behind to outlast the 20-time grand slam champion he’d never beaten to win 3-6, 6-4, 3-6, 6-4, 6-2, scuttling a much-fancied matchup between Federer and Rafael Nadal in Sunday’s final and becoming the lowest ranked major semi-finalist since Germany’s Rainer Schuettler, then 94th in the world, reached the last four at Wimbledon in 2008.

Federer, in control if not command in the early stages, slowly came apart during a marathon fourth set, took a medical timeout for a sore upper back and neck before the fifth and was promptly broken in his first two service games of the decider, clearly compromised, as the white-knuckle tension of the previous hour was quickly replaced by sobering anticlimax.

“Just needed to try to loosen it up, crack it and see if it was going to be better,” Federer said. “Physically, yeah, I felt it the whole time. That’s it. I was able to play with it. My bad not to win.”

The third-seeded Swiss made 61 unforced errors to 40 winners but the miscues, including 33 off an uncharacteristically erratic forehand, only mounted as Dimitrov dragged him further into deep waters in the third and fourth sets over a series of gruelling baseline rallies. The strategy, as the Bulgarian described it afterward, was attritional war.

“One of the only things for me was try to keep him as much as possible on the court,” he said. “I did that very well. A lot of long games. Yeah, clearly in the end he was not at his best. I used every opportunity I had.”

Dimitrov, who had been on the wrong end of all seven career meetings with Federer and lost 16 of the 18 sets played, then breezed to the finish line and into a third career major semi-final, where he will face No 5 seed Daniil Medvedev on Friday.

Federer, who was the oldest player to reach the last eight at a major since a 39-year-old Jimmy Connors’ semi-final run at the 1991 US Open, was off to the races after breaking in his first return game and taking the opening set in under a half hour, but Dimitrov was undeterred and drew first blood in the seventh game of the second on his way to leveling the match at a set apiece.

Even as Federer broke twice in the third to comfortably stake a two-sets-to-one advantage, the errors started to pile up as the rallies began to lengthen on Dimitov’s mandate. Try as he did to shorten the points with frequent net approaches – nearly three times as many (56) as Dimitrov (20) on the night – Federer’s unraveling continued with one unforced error after another coming forward.

Then came the taxing 55-minute fourth where Federer failed to convert all of his six break-point chances as he buckled under the constant pressure of Dimitrov’s deep, flat baseline groundstrokes peppered with unpredictable variety within the points. He was pushed in nearly every service game, including a feature-length 22-point hold while serving at 3-4 which appeared to exact a lasting toll on his fitness and nerve.

“I was very happy even though I lost the game, I did exactly what I wanted to do,” Dimitrov said. “I think even when I lost that game, I was actually smiling going through the changeover because that game must have hurt him a lot. For me, it actually filled me up.”

After the 28-year-old held to force a decider, Federer disappeared from the court for nearly 10 minutes for medical treatment as his emboldened opponent began doing push-ups by his chair to prevent cramping.

Yet Federer’s form only dipped upon his return as the fifth set rapidly got away from him while a hush enveloped the 23,771-seat stadium. When he finally sprayed a forehand wide on match point after three hours and 12 minutes, the 38-year-old was left to rue another failed bid for a sixth championship at Flushing Meadows, where he has now gone 11 years without a title after winning five straight from 2004 through 2008.

“Just low,” said Federer, who fell to 43-2 at the US Open against players outside the top 50, the first blemish coming last year against Australia’s John Millman. “Just disappointed it’s over because I did feel like I was actually playing really well after a couple of rocky starts. It’s just a missed opportunity to some extent that you’re in the lead, you can get through, you have two days off after. It was looking good.

“But got to take the losses. They’re part of the game.”

When asked about his future major prospects, Federer said: “I don’t have the crystal ball. Do you? So we never know. I hope so, of course. I think still it’s been a positive season. Disappointing now, but I’ll get back up, I’ll be all right.”

Dimitrov, a former junior world No 1 who climbed as high as third in the ATP rankings only two years ago, entered the season’s final grand slam with 12 wins in 27 matches all year and losses in seven of his last eight, including one to the world No 405. He’s now into the semi-finals of a major for the third time after previous runs at the 2014 French and 2017 Australian.

“Despite the fact that I was losing very tough matches, close matches against players that I shouldn’t lose [to], yet I did, I kept on believing in the process, kept on working, kept on trying to improve whatever else I had to improve on my end,” Dimitrov said. “I really controlled the things that I could. I think that’s as simple as that. Sometimes the most simple things are hardest.”

He added: “It was not a pretty time. I’m not going to lie. But for me also today, I don’t want to sound too humble, but it was just another match for me really. I don’t want to say I had nothing to lose, because I felt I did.”