Frances Tiafoe (right) had lost his previous two meetings with Rafael Nadal
American Tiafoe thrilled the home crowd with a 6-4 4-6 6-4 6-3 win over four-time champion Nadal in New York.
The defeat ended the Spaniard's bid for a record-extending 23rd major singles title.
Nadal led the fourth set 3-1 before Tiafoe hit back, winning five games in a row to secure his quarter-final spot.
He will face Russian ninth seed Andrey Rublev for a place in the semi-finals at Flushing Meadows.
Tiafoe, seeded 22nd, threw his racquet to the floor and covered his face in disbelief as his victory was confirmed by a netted Nadal backhand.
After thanking the crowd he covered his face with his towel, taking in the atmosphere on a raucous Arthur Ashe Stadium.
"Something special happened today," the 24-year-old said on court.
"I don't know what to say, I'm so happy. He's one of the greatest of all time and I played unbelievable."
Nadal has never looked settled in New York this year but that is not to take anything away from Tiafoe, who played a clever match.
The result means that Marin Cilic, who won the 2014 US Open, is the only Grand Slam singles winner left in the men's draw.
Cilic plays Carlos Alcaraz in Monday's night session on Arthur Ashe Stadium with Italian 11th seed Jannik Sinner taking on unseeded Belarusian Ilya Ivashka.
Rafael Nadal was competing at his first US Open since 2019
Nadal went into this match with a 22-0 record in Grand Slams this year, having won the Australian Open and French Open titles before withdrawing from Wimbledon after his quarter-final victory with an abdominal injury.
That injury restricted his build-up to the US Open with Nadal arriving at Flushing Meadows having playing only once since, a defeat by Borna Coric in Cincinnati.
He has struggled for fluency in New York, particularly in his second-round match against Fabio Fognini, and showed similar nerves on serve against Tiafoe.
Having changed his ball toss to protect the injury that ended his Wimbledon campaign, Nadal looked shorn of speed and confidence on his serve, and was broken by Tiafoe at 3-3 in the opener.
After losing the first set, Nadal disappeared off court with the physiotherapist for eight minutes and appeared to have strapping added to his wrists.
Although his serve never clicked - he finished with nine double faults to nine aces - he was able to take advantage of one poor Tiafoe service game at 5-4 in the second, being gifted the set by a Tiafoe double fault.
The third set mirrored the first, Tiafoe breaking for a 4-3 lead with a fine backhand winner, and the American delighted his home crowd as he closed it out with an ace.
Nadal appeared reinvigorated in the fourth set and was helped by Tiafoe becoming distracted as the roof closed during his service game at 2-1 down.
Nadal broke serve but Tiafoe, helped by two Nadal double faults, responded instantly, and produced some excellent counter-punching to break twice more on his way to clinching victory.
Despite the defeat, Nadal could still move to the top of the men's rankings after the tournament following defending champion Daniil Medvedev's loss to Kyrgios on Sunday.
Spain's Alcaraz and Norway's Casper Ruud would need to reach the final at least to have a chance to become the world number one.
Frances Tiafoe had previously never gone beyond the fourth round in New York
Tiafoe has endured some difficult losses in recent weeks, squandering strong positions against Taylor Fritz and Nick Kyrgios, but he showed no signs of nerves against Nadal.
He has spoken before about the difficulties he and his family overcame together and his more unusual route into tennis.
His father worked on a construction crew developing the Junior Tennis Champions Centre (JTCC) in Washington. With his mum working night shifts as a nurse, Tiafoe and his brother were often at the JTCC for long periods of time and subsequently developed their tennis skills on the courts there.
He previously reached the quarter-finals of the Australian Open in 2019 but the win over Nadal is the biggest in his career to date.
"Honestly when I first came on the scene I wasn't ready for it mentally and mature enough," he said on court.
"I've been able to develop and I have a great team around me.
"I'm happy I won in front of my mum, my dad, my girlfriend and my team and to have them see what I did today."
-- Courtesy of BBC Sport