The 37-year-old American dismantled Halep's game to race through the opening set in 20 minutes.
Romania's Halep, 27, recovered in the second, breaking in what proved to be the final game.
Williams, seeded 16th, saved three break points for 3-3 in the decider, crucially winning the next game to seize control.
The 23-time Grand Slam champion comfortably held her next service game to edge closer, then served out for victory in one hour and 47 minutes.
Triumphantly punching the air with both arms as she gave a steely stare towards her box, Williams showed how much relief she felt at beating the world number one.
"It was an intense match and there were some incredible points, but I love being here," she said. SHARE THIS STORY USING ANY OF THE BUTTON BELOW ⬇ PLACE YOUR TEXT ADVERT BELOW ⬇⬇⬇