The 39-year-old went toe-to-toe with the Romanian second seed over 80 minutes on Rod Laver Arena before she was finally able to move to within two victories of a record-equalling 24th Grand Slam title.
Williams hit some ferocious forehands and moved around the court with a freedom that she has not enjoyed for a good while to set up a semi-final meeting against in-form Japanese third seed Osaka.
"I think this was the best match I have played at this tournament, for sure," Williams said after celebrating her win to the accompaniment of canned applause as Melbourne's coronavirus lockdown kept the fans away for a fourth day.
"I knew it had to be going up against the number two in the world. I had to be better and I was, so I'm excited."
If any match at this year's tournament deserved a crowd, it was this. There were nine breaks of serve as two great competitors punched and counter-punched over lengthy rallies.
Williams was always in front in the first set but needed to dig deep to wrestle back the momentum after Halep took a 3-1 lead in the second.
The match turned decisively when Williams broke for 4-3 after a 13-shot rally where she showed incredible athleticism to get to a couple of shots that would have defied most players.
Seven minutes later, she wrapped up the contest with a huge forehand, her 24th winner.
"My feeling after this match is that I was not that far (away) but she was stronger in the important moments," said Halep.
"I'm not that disappointed with myself."
Williams has not landed one of the game's major prizes since her seventh title at Melbourne Park in 2017, with Halep's victory in the 2019 Wimbledon final denying her one opportunity to match Margaret Court's record.
After gaining a measure of revenge for that defeat, Williams has the chance to avenge another when she plays Osaka, who won the 2018 U.S. Open final between the two.
"I feel this is a great opportunity for me just to do my best in the first Grand Slam of the year," she said.