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 (8-6), only for an aggressive Elena Rybakina to level matters by dismantling world No.7 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 No.1 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.
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 (7-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 No.1 herself.
Britain are 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 (7-4) victory over Ena Shibahara.
Japan's hopes of salvaging the tie then 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 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."
Italy will play Ukraine in the first semi-final on Friday before the US-GB match on Saturday.