The seven-time major winner hit three aces and broke the Romanian twice en route to taking the first set.
But Halep rallied to take the second set before Williams finally edged her out in the tiebreaker.
"On the last match point I went for it. I wanted to leave it all out there on the court," said Williams, playing just her third tournament following a seven-month absence due to illness.
"A match like that can be good. We hit a lot of balls and I was able to get that clay-court mentality right away. I have to keep remembering I'm on clay."
Stosur saved six break points to take the tight match from the Croatian, 7-5, 4-6, 7-6 (5).
"Petra was playing really well, and it really went down to the wire today," Stosur said. "I thought my level got better and better as the match went on, and the last half of the third set was the best tennis we played."
"She's an up-and-coming young player who hits the ball well and is a great athlete," Stosur said. "I will have to be prepared and be on my game."
Also, eighth-seeded Li Na of China hit seven aces to ease by Gabrine Muguruza Blanco of Spain 6-2, 6-4.