Jo-Wilfried Tsonga had won his singles match against John Isner, romping to a 6-3 6-2 victory to give his nation the lead.
Williams looked in trouble at a set and 3-0 down against Mathilde Johansson, but dug deep to turn the contest on its head and triumph 3-6 7-5 6-4.
In the doubles decider Isner's serve fired as the pair held their nerve to win in a champions tie-break 6-7 6-2 10-8.
"Mathilde's a tough player. She hits the ball hard and low, and I'm tall so it's hard to get low," Williams said. "I was just thinking, at least if I'm going to lose this match, I was going to try to work on my game. In the end, I got a win for the US."
The US have now won both their group matches and along with Spain are assured of a place in the semi-finals.
- Sports & Recreation
- Mathilde Johansson
- John Isner