The tie hung in the balance after American Emma Navarro had dramatically saved two match points to outlast Yulia Putintseva 7-5, 2-6, 7-6(6), only for an aggressive Elena Rybakina to level matters by dismantling world number seven Pegula 6-4, 6-1.
Kazakhstan, eyeing their first final appearance, then rolled the dice by selecting Rybakina and Putintseva for the decisive doubles clash.
But the Americans - spearheaded by doubles world number one Townsend - had other plans when skipper Lindsay Davenport teamed her up with Pegula.
The US pair survived an early scare when they stared down three break points at 0-40 in their opening service game, but managed to hold serve before seizing control.

While Pegula patrolled the baseline, Townsend proved clinical at the net as both Rybakina and Putintseva dropped serve, helping the Americans pocket the first set.
Although Kazakhstan struck first in the second with an early break, the US broke back immediately and forced a tiebreak, which they dominated to seal a 6-2, 7-6(1) victory.
"I haven't played with Taylor in such a long time, so that was fun to get back playing with her," said Pegula, a former doubles world number one.
"I always love playing with a lefty. Makes my life a lot easier. I think our games complement each other really well.
"She's an amazing doubles player. She could probably play with anybody."
Great Britain beat Japan
Great Britain are also seeking their first BJK Cup title, and they cruised past Japan when Sonay Kartal and Katie Boulter won their singles matches.
Kartal, who reached the fourth round at Wimbledon for the first time this year, gave Britain the lead with a 6-3, 7-6(4) victory over Ena Shibahara.
Japan's hopes of salvaging the tie fell on the shoulders of Moyuka Uchijima, but she was no match for Boulter, who wrapped up a comfortable 6-2, 6-1 victory in 68 minutes.
"Sonay put in a clinical performance so she makes it easy to follow," Boulter said.
"I stayed out there as much as possible and tried to focus on myself. I am super happy to be through, and it is nice to have some British fans here.
"I am so pleased. This team qualified earlier in the year, and we showed a lot of heart. The team deserves to be here, and hopefully, we can go to the final. Hopefully, this is our time now."
BJK Cup semi-finals
September 19th: Italy vs Ukraine
September 20th: United States vs Britain