The 28-year-old Bulgarian ousted the five-time champion 3-6, 6-4, 3-6, 6-4, 6-2. It was his first victory over the Swiss in eight meetings and one of the biggest wins in his career since lifting the ATP Finals in 2017.
The triumph in New York came towards the end of an injury-plagued season in which Dimitrov has slumped to number 78 in the world.
"It was not a pretty time. I'm not going to lie," Dimitrov said. "It was that low that I don't even want to go there any more.
"It was just obviously injury, losing points, ranking. That's the lowest point of any player.
"The past six, seven months have been pretty rough for me. But I had somebody to lean on, my friends, my family. I kept on believing again in the work, the rehab I had to put behind my shoulder, the exercise, the practice."
Federer, who was diminished by an injury to his back in the latter stages of the match, said: "This is Grigor's moment, not my body's moment. "It's OK. It's how it goes. I tried my best. I fought with what I had and that's it."
Dimitrov will next play the fifth seed Daniil Medvedev after the Russia dispatched the 2016 champion Stan Wawrinka 7-6, 6-3, 3-6, 6-1 to reach a Grand Slam semi-final for the first time.