Federer, 36, struggled with a back injury in the build-up to the tournament and left the court after the second set for a medical timeout.

"I just needed a bit of a rub on my back. Or my… bottom," he said on court afterwards.

He later added: "I just felt something, sort of my muscle being tight at the back. Sort of my quad, I guess.

"I just didn't want Philipp to wait. It was more precaution. It's all good. No problems there. I'm not worried about it. I'm sorry I had to do it."

Federer upstaged by Del Potro 'epic'

The five-time champion produced another impressive performance, but for once the spotlight was elsewhere as Del Potro's comeback gripped Flushing Meadows.

The noise from the 8,000-seater Grandstand court outstripped that from the 24,000 spectators on Arthur Ashe Stadium as Del Potro saved two match points with thumping aces, on his way to setting up a rematch of the 2009 final he won against Federer.

"I played one of the epic matches of my career here at the US Open, which is my favourite tournament, in front of a great crowd," the Argentine said.

"I was thinking to retire in the middle of second set because I couldn't breathe, I couldn't move well, and Dominic was dominating the match so easy."

The 28-year-old was broken in the first game and seemed to be struggling with his eyesight.

Having lost the first set in 36 minutes, and after receiving medical treatment, the former champion trailed 6-1 3-0 and finally hit his first winner in the 12th game, but then wasted three break point opportunities.

The third set was far more competitive, as Del Potro appeared to be buoyed by medication and a partisan crowd. He broke Thiem in the second game and raced clear to take the set.

The 24th seed saved two match points in the fourth with aces and the crowd went wild when Del Potro won the resulting tie-break to take it to a decider.

There was more drama when Del Potro failed to convert three break points while 3-2, 0-40 up in the fifth, but an hour after facing match points, the Argentine completed the unlikely comeback as Thiem served a double fault.

After needing five sets to win his first two matches in New York, Federer made it back-to-back three-set wins.

The 19-time Grand Slam champion did not face a single break point over the course of one hour and 50 minutes.

He took control in the seventh game with the first of four breaks, dominating the second set and clinching victory in game 12 of the third as a tie-break loomed.