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.”
Earlier, fifth-seeded Sam Stosur also needed three sets to beat Petra Martic.
Stosur saved six break points to take the tight match 7-5, 4-6, 7-6 (5).
BMW OPEN: In Munich, third-seeded Marin Cilic beat German veteran Tommy Haas in straight sets on Saturday to reach the final, where he will face 2007 winner Philipp Kohlschreiber.
Cilic, the 2010 finalist, dropped just five points from his own serve as the 23-year-old Croat defeated Haas 6-3, 6-4.