Badosa, of Spain, reached the tournament semifinals in her first time at the season's opening clay-court tournament. And she was rarely pressured by Australia's Barty on the way to her first victory over a No. 1 player.
Badosa broke Barty's serve five times, including the last two times Barty served after the second set was tied 3-all.
"I'm still a little bit shocked. I can't believe what just happened," the 23-year-old Badosa said. "When the ball went out, I was like, 'What just happened right now?'"
It was the second time in her past four events that Badosa advanced to the semifinals. She'll face Russia's Veronika Kudermetova, the 15th seed, on Saturday for a spot in the championship final.
Barty was coming off a victory at the Miami Open last Saturday and looked strong in her first two matches in Charleston. But she fell behind Badosa and struggled to handle her opponent's serve.
Despite the defeat, Barty said she was glad for the run that took her this far in preparations for the French Open.
"I think I took a few too many risks" in the match, Barty said. "But I think it's been an exceptional three weeks to start off our trip and we can [get] nothing but the positives from it."
As Badosa got closer to the upset, she worried about Barty's ability to rally. "Sometimes these matches are very tough to close," Badosa said. "Today, I'm quite happy that I managed it well."
Danka Kovinic of Montenegro rallied after losing the first set to oust Yulia Putintseva of Kazakhstan 6-7 (2), 7-5, 6-1. It's the first time Kovinic, ranked 91st in the world, advanced to a WTA semifinal in 14 tournaments since the Taipei OEC Open in November 2019.
"I really think this clay suits me well," she said. "I just feel really, really good here."
Kovinic will face Ons Jabeur of Tunisia on Saturday for a spot in the championship final. Jabeur, the 12th seed, defeated the youngest player in the field, 17-year-old American Coco Gauff,
Gauff fell against Jabeur and later withdrew from her doubles match with a right hip injury.
Jabeur hasn't been to a WTA semi in her past 18 events since October 2019 at the Tianjin Open in China.
Jabeur had reached the quarterfinals five times in that stretch without advancing. "So many close quarterfinals," she said. "I'm really glad that I got the win. I'm looking forward to playing my game, looking forward to going further as I can."
Kudermetova beat former U.S. Open champion Sloane Stephens 6-3, 6-4 to reach the final four.
All four semifinalists are looking for their first career WTA titles.