After the first set, and with Williams in top form, it looked to be a straightforward night at Key Biscayne for the seven-time Miami champion, but the contest turned into an 128-minute slugfest as Halep simply refused to fold.
Romania's Halep raised her game in the second set and handled Williams' serve superbly as both players held until the 23-year-old world No 3 broke for a 5-4 lead before serving out to force a deciding set.
Williams again looked to have finished Halep off when she broke in the second game of the third set and raced into a 3-0 lead, but Halep dug deep once more to extend the contest.
Halep then broke back and held to level at 5-5.
She was the last player to beat Williams on the WTA Tour, and another upset appeared on the cards, but the top seed held and then broke to love to clinch victory.
But Williams was unhappy with her performance, despite reaching the final.
"I hit more errors than I did in my last match, which I thought was impossible," she said. "I'm just not at my best level right now which is a little frustrating."
Williams has held top spot in the rankings for 110 weeks though, and knows what improvements she has to make.
"I feel like the match was on my racquet and I really had opportunities in the second. I just didn't take them," she said.
"That is something I can't do going into the Grand Slams coming up."