The 32-year-old Spaniard led by two sets to love before Basilashvili, ranked 37th in the world, recovered to take a third-set tie-break.
But the top seed broke twice as Basilashvili faded physically in the fourth to win 6-3 6-3 6-7 (6-8) 6-4.
He faces ninth seed Dominic Thiem next.
For Thiem, Tuesday’s quarter-final offers a chance to avenge his defeat by Nadal in his first Grand Slam final at June’s French Open.
The Austrian broke late in the first set and twice in the second before winning the third in a tie-break.
It is the first time Thiem has reached the last eight in New York.
South African Anderson was also runner-up at Wimbledon earlier this year.
French Open finalist Thiem called the win “one of his best matches ever”.
Twelve months ago the 24-year-old had two match points in the fourth round against Juan Martin del Potro but lost in five sets.
“It’s a dream coming true,” said Thiem. “I was really close last year, but I couldn’t close it out.”
Elsewhere, Britain’s Jamie Murray and partner Bethanie Mattek-Sands ousted eighth seeds Abigail Spears and Juan-Sebastian Cabal to reach the quarter-finals of the mixed doubles at the US Open.
Scot Murray, 32, and his American partner won 6-4 7-6 (7-2).
Murray won the title last year with the now retired Martina Hingis.
He is also still in the men’s doubles alongside Brazilian partner Bruno Soares, while fellow Briton Dom Inglot is also in the third round.
Murray and Mattek-Sands will face either fourth seeds Latisha Chan and Ivan Dodig or Nadiia Kichenok and Wesley Koolhof for a place in the semi-finals.