Perth, Australia -- Roger Federer won the bragging rights over fellow tennis great Serena Williams as they faced each other on court for the first time on Tuesday, with Federer spearheading Switzerland's 4-2, 4-3 (3) victory in a mixed doubles decider at the Hopman Cup.

"I was nervous returning. People talk about her serve so much and I see why it is such a wonderful serve because you just can't read it," Federer said.

Federer and playing partner Belinda Bencic overcame Williams and Frances Tiafoe in the Fast4 format in front of a 14,000 capacity crowd.

Get Breaking News Delivered to Your Inbox

After the match, Federer tweeted a photo of himself with Williams: "Oh what a night."

Oh what a night 🎾🔥 pic.twitter.com/Fj9arBT6Ni — Roger Federer (@rogerfederer) January 1, 2019

"It was so fun. This is super cool that we get to do it at such a pinnacle point of our careers," Williams said.

Federer and Williams have won 43 Grand Slam singles titles between them.

Defending champion Switzerland will qualify for Saturday's final if it beats Greece on Thursday. The United States, which lost to Greece on Monday, can't now advance.

The much-hyped contest lived up to the billing immediately with Federer almost running down Williams' smash into the open court. Williams and Federer both served well against each other, but Federer's sublime touch at the net proved decisive.

Williams grabbed at her right shoulder on several occasions late in the second set but played the match out.

Earlier, Federer beat Tiafoe 6-4, 6-1 in the men's singles before Williams leveled the tie with a comeback 4-6, 6-4, 6-3 victory over Bencic.