In the biggest mixed doubles drawcard in the 31-year history of the tournament, in what is expected to be its final edition, Federer teamed with Belinda Bencic to win the match in straight sets under the Fast4 format and win the Group B tie for Switzerland.
Switzerland's Federer and Bencic will team up to play Williams and Tiafoe of the US in the deciding mixed doubles.
The Swiss maestro had talked before the match of his nervousness at facing the feared Serena serve and his fears seemed confirmed as he was unable to cope with two deliveries in her opening service game, but thereafter he took control of the match with Bencic.
Williams held up her end, dominant on serve throughout, but Frances Tiafoe was broken in the first set before Federer served it out in the second set tie break to seal the tie.
Williams, 37, had wraps on both ankles and needed help from trainers during the match, but said she was happy to be back on the court in competition.
"It's great to be back out in match day, and it's great to be back out here", she said after the match. "You're a superman over there because it's hard with just one", she said.
"I really can not imagine how". Belinda won one point more than Serena but she couldn't do enough in the crucial points, suffering three breaks from as many chances and stealing Serena's serve twice from five opportunities.
"I guess what you're seeking here is confirmation to see is everything there that you thought there was, or is there any fixing still to be done in the coming weeks".
In his singles match, Federer scored successive wins to start the new season with an impressive 6-4, 6-1 victory over Frances Tiafoe. I think his serve is super-underestimated.
As a result of the win, Switzerland progress through to the final on Saturday, while the United States of America will next take on Great Britain.
Putting her amazingly toned figure on full display, Serena looked sensational in the red skater-style dress with a sweetheart neckline.
Federer and Bencic are the defending champions. Roger Federer has 20 titles, a mark he reached in 2018.
The pair battled it out for over two hours in their first round match before Venus broke through in the sixth game of the decider to set up victory.
"It was definitely a relief", Williams said of the result.