The 18-year-old Bencic won her second WTA Tour title after breaking through this summer on grass in England at Eastbourne. She's ranked 20th.
"It's like I cannot believe it, and it's amazing," Bencic said. "I have no words for this, and definitely talk about a tough draw."
Canada's Eugenie Bouchard was the first to fall. Fourth-seeded Caroline Wozniacki was next, followed by Sabine Lisicki, fifth-seeded Ana Ivanovic, the top-ranked Williams — who lost for just the second time all year — and finally the second-seeded Halep.
Halep was hampered by a left leg injury, cramps and heat exhaustion and stopped in the third set.
"I was thinking that I need a miracle to finish the match," Halep said. "I knew that I had no power, so I tried just to finish the match, but at 3-0 I said there is no sense to continue and I stopped."
Halep tried to shake out her leg pain at times in the opening set but, with a 6-5 lead, called for a trainer to work on her left quadriceps. She returned with a bandage taped to the outside of her leg.
Bencic held serve and trailed 1-4 in the tiebreaker before taking control with four straight points. Halep misfired wide to set up a set point and Bencic converted when the Romanian found the net.
Down 1-2 in the second set, Halep had the trainer come out again to rub her left leg under the knee. She had ice towels wrapped around her neck and upper legs while her blood pressure was checked.
The vocal pockets of Halep supporters in the near-capacity crowd at the 8,000-seat venue seemed to spur her on and she came through to take the second set.
Halep took another break before the third set and went back to the locker room before returning wearin a hat. Bencic fumed after the interruption and voiced her displeasure with the umpire.
Her focus quickly returned and she overpowered the fading Halep. Bencic broke her serve in two of the first three games and her opponent could not carry on.
"I stayed focused and I made the (score) 3-0," she said. "So I can be proud of how I fought today as well because I (was also) up there and I was down."