Barty, who won the first set, broke Williams early in the second set to surge further ahead before Williams willed her way back.

“I lost the first set and I thought I’ve got to try harder," she said.

"I’ve got to just try harder and Serena came out,” Williams said.

Barty’s plan to move Williams from side to side was initially paid dividends but the former world No.1 drew on her unrivalled fighting qualities.

Many had doubted Williams would have the energy reserves to stave off Australia’s 17th seed but there were no signs of that and she overcame Barty in one hour and 46 minutes.

“It’s disappointing because I was well and truly in the match and I felt off the baseline I was no issues at all,” Barty said.

“I would love to have five or six forehands again, a couple of those errors, and a couple more first serves, and I think it could be a different outcome," she added.