The Belarusian 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 quarter-final.
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, who beat Sorana Cirstea, also on Monday AEST, 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.
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.
American Pegula clinched a resounding 6-3 6-4 win over Cirstea, in the Romanian's final Grand Slam appearance.
The 2024 runner-up Pegula kept alive her bid for a maiden major title, overcoming a resurgent Cirstea who has enjoyed a late-career renaissance, reaching a career-high top-20 ranking, before retiring at the end of the season.
The victory was Pegula's second over Cirstea in three weeks after she edged the Romanian in the Cincinnati Open Round of 16.
"I have a lot of respect for her. She's such a great competitor," Pegula said on the Louis Armstrong court.
"We actually hadn't played in a while up until the last few weeks. They were two really tough matches. It was definitely really intense."