Paired with Belinda Bencic, Federer beat Williams and Frances Tiafoe 4-2 4-3 (5-3) to give Switzerland a 2-1 win over the United States in their round robin match.
More importantly, it was the first and probably last time that fans would get to see the two tennis players, widely regarded as the greatest of all time, battle it out across the net in a competitive match -- and after it was over they even had time to pose for a selfie that is sure to go viral.
Federer eventually clinched it for the reigning champion by claiming the winning point in the truncated tiebreak used in mixed doubles with a perfect angled volley.
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.
"I was nervous returning because it's a wonderful serve and you just can't read it," said Federer in the post-match interviews.
"It was great fun and she is a great champion. You can see how focused she is and that's what I love about her."
In truth, Serena was not given the chance to show much of the doubles prowess that has seen her win 16 grand slam titles in that discipline on top of her 23 in singles.
Partner Tiafoe lost his service for the Americans to lose the opening set and she also appeared to be nursing a right shoulder injury although she insisted it was of no concern with the Australian Open looming.
However, despite the disappointing defeat which leaves the United States unable to reach the final of an event it has won six times, Serena clearly relished testing herself against Federer.
"It was a great experience, I'm sad it is over, I was just warming up," she joked.
Serena also had no doubt as to the status of the 20 grand slams winner.
"I mean the guy is the greatest of all time, both on and off the court," she said.
The widely-anticipated clash has been the highlight of the 31st staging of the Hopman Cup with a record 14,029 packing into the Perth Arena to see the match-up.
Switzerland will defend its unbeaten record against Greece in its final round robin match Thursday with the US taking on Britain.
Serena, Fed win singles matches
Earlier, Williams had shown her competitive mettle by coming through a testing singles encounter with Bencic to level the tie at 1-1 after Federer's 6-4 6-1 straight sets win over Tiafoe.
Leading 4-1 in the first set, Williams looked set to be cruising to a comfortable victory until her 21-year-old opponent hit back to win the next five games and take the opener.
Williams, tuning up for the first grand slam of the season, upped her game under pressure to take the next two for a 4-6 6-4 6-3 victory to set up a competitive finale with Federer.
"It was definitely a relief. She played really well. I knew I could play better," she said.
Federer had also looked in fine form as he looks to defend his Australian Open crown, gaining a single break to take the first set against his 20-year-old opponent and then racing through the second.
Meanwhile in regular WTA action, Serena's elder sister Venus showed she is still a force by beating Victoria Azarenka 6-3 1-6 6-3 in a battle of former world number one's at the Auckland Classic.
The pair were on court for over two hours in their first round match before Venus broke through in the sixth game of the decider to set up victory. "Maybe one of the toughest first round matches I have played," she said.
In Brisbane, Naomi Osaka, who beat Serena Williams in their controversial US Open final last September, showed she will be a force as she bids to win successive grand slams, reaching the quarterfinals with a 6-3 6-2 win over Destanee Aiava.