Roger Federer gave away a lead against a guy he'd never lost to and was beaten 3-6, 6-4, 3-6, 6-4, 6-2 by 78th-ranked Grigor Dimitrov in the U.S. Open quarterfinals before a stunned crowd at Arthur Ashe Stadium.

The 38-year-old Federer took a rare-for-him medical timeout after the fourth set, leaving the court with a trainer. It was not immediately clear what might have been wrong with Federer, although he did appear to be flexing his back after some points.

FEDERER CAN BE OLDEST MALE SLAM SEMIFINALIST SINCE CONNORS

When play resumed after a break of nearly 10 minutes, Federer's form never picked up. He finished with 61 unforced errors, 33 on the forehand side.

Federer had been 7-0 against Dimitrov, taking 16 of their previous 18 sets.

Federer would have been the oldest Grand Slam semifinalist since Jimmy Connors was 39 at Flushing Meadows in 1991. He also was trying to add to his totals of five U.S. Open championships and 20 major trophies in all.

CLICK HERE TO GET THE FOX NEWS APP

Instead, Dimitrov advanced to his third major semifinal, first in New York. He will face No. 5 Daniil Medvedev on Friday.