The 28-year-old claimed a heroic 1-6, 2-6, 6-1, 7-6 (7/1), 6-4 victory over the sixth-seeded Austrian on a rocking Grandstand court, describing it as night he would remember forever.
Del Potro famously defeated Federer in the 2009 final for his only career Grand Slam title before his career was almost torpedoed by a succession of wrist surgeries.
Montreal Masters: Dominant Federer fires into semis
Federer, the third seed, eased into the last-eight with a 6-4, 6-2, 7-5 win over Germany’s Philipp Kohlschreiber, taking his record over the German veteran to 12-0.
The day belonged to Del Potro, who celebrated his win, which came off a Thiem double fault, by stretching out his arms, head facing the night sky, as his legion of fans, many dressed in the light blue colors of Argentina's famed football and Pumas rugby teams, celebrated wildly.
"Oh my God," said Del Potro, who had been 2-5 down in the fourth set. "I was sick the last two days. I came here trying to play the best I can and then when I see this crowd cheering for me, I was trying to play better every game. I will always remember this."
Nadal, Federer march on in US Open
Federer has a 16-5 advantage over Del Potro but they have split their last six meetings.
The 36-year-old Swiss maestro didn't face a break point against Kohlschreiber with his biggest challenge having to take a medical time-out off court at the end of the second set.
"I needed a rub on my back... or bottom and I didn't want to do it in front of you guys," he explained before he turned his attentions to Del Potro. "It's great to see him back on tour. He's had a rough ride with wrist problems. He's a good guy."
Elsewhere, top seed Rafael Nadal claimed his 50th win at the US Open and will meet Russian teenager Andrey Rublev in the last-eight clash.
"I played a solid match with not many mistakes," said Nadal, the reigning French Open champion.
Rublev, ranked 53, has won 13 of his last 17 matches after breaking the top 100 for the first time in June. "Rafa is a real champion. I will try to do my best — I have nothing to lose," said Rublev.
In the women's event, world number one Karolina Pliskova set-up a quarter-final date against America's CoCo Vandeweghe.
Estonia's world number 418 Kaia Kanepi also reached the quarter-finals, just the second qualifier to make the last eight.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ