The Belarussian battled through 6-4 6-3 on Arthur Ashe Stadium in a bizarre match which featured 11 breaks of serve from 19 games before booking her place in her 17th career major quarterfinal.
Sabalenka has spent 99 weeks at the top of the rankings but she needs to win a third straight Flushing Meadows title – and for current No.2 Elena Rybakina to lose before the semi-finals – if she is to reach a century.
Coco Gauff and Jessica Pegula are also within striking distance in a four-way battle for the top spot.
"It's super challenging but once again it's important to focus on yourself," said Sabalenka, who had to come from a break down in the second set against the popular Townsend.
"I was like 'OK, you are down the break, just try to return the serve and put as much pressure on her as possible basically.
"I was just trying to stay focused on myself, not only point by point but ball by ball.
"I'm happy I was able to turn around the second set, I think it was a key moment."
Sabalenka will next play Wimbledon champion Linda Noskova, after the Czech came through a titanic battle against Marta Kostyuk in a repeat of their semi-final at SW19 later on Sunday.
Ukrainian Kostyuk saved five match points, two at the end of the second set and three in the decider, before Noskova eventually got over the line 7-5 5-7 6-4.
The Czech beat Kostyuk in straight sets en route to the title at the grasscourt major this year but endured a far tougher encounter at Louis Armstrong Stadium, finally sealing victory on her sixth match point with an unreturnable serve.
"I am more than relieved. This match was so tough. I mean, emotionally, more than physically," said Noskova, who crumpled to the court as she finally got over the finish line.
"I feel like a huge rock fell off my heart at the end."