For Sharapova, it's her first loss at night at the US Open, moving her to 23-1 all-time under the lights at the Open.
The 29-year-old, who had never previously beaten a top-10 opponent, appeared to have even less chance of winning with Federer a set and a break up and holding two set points, but he somehow clawed his way back to clinch a 3-6 7-5 7-6 (8/6) 7-6 (7/3) victory.
Federer, like any great champion, refused to throw in the towel and showed emotion for the first time after breaking for a 4-2 lead in the fourth.
The No. 20 seed had to work much harder than she had so far in the tournament, where she had won 22 consecutive games leading into the match Monday.
But Millman is in the form of his life, having surged to the fourth round of a grand slam for the first time with a series of upsets - including that of 14th seed Fabio Fognini. That was the first time in tournament history that the U.S. Open created an extreme heat policy for men's matches - players can opt for a 10-minute break between the third and fourth sets - similar to what's standard on the women's tour, when there can be a delay between the second and third sets.
Madison Keys eased into the quarter-finals of the US Open with a 6-1 6-3 victory over Slovakia's Dominika Cibulkova.
His next assignment is a rematch of June's French Open final, in which he crushed Thiem in straight sets to win his 17th major.
Trans Mountain ruling increases uncertainty among resource industry groups
Greenpeace and others called the court's decision a "major victory" for indigenous rights and efforts to curtail global warming. The court combined into one case almost two dozen lawsuits calling for the energy board's review to be overturned .
But it's his father Ron, nicknamed "The Fox", who has become somewhat of a social media star, after getting lost on his way to watch his son play at the Wimbledon earlier this year.
A young tennis fan has left Novak Djokovic in stitches at the US Open with an adorable impersonation of the two-time champion.
The 14th-seeded Keys will play the victor of the Carla Suarez Navarro vs. Maria Sharapova match in the night session at Arthur Ashe Stadium.
Coming into the match the number-two seed, Federer saw set point slip away from him twice, in the second and third sets, as the resilient Australian, Millman, playing his first-ever Grand Slam fourth-round match, held his nerve.
"Felt like a deer in the headlights to begin with, to be honest", he said courtside.
The Spaniard will be at that stage for the second time at the U.S. Open, five years after her other run to that round.
The Ukrainian got some help from her opponent. The big win for Navarro comes on her 30th birthday.