The second-seeded Serbian won five games in a row to take the opening set and also had match point in the second, but Williams fought back to take the match into a decider.
However, another break of serve early in the third proved crucial as Ivanovic went on to win 6-2 5-7 6-4 in two hours and 19 minutes.
It marked Ivanovic's first title since winning in Bali at the end of 2011 and she told the WTA Tour website: "It's amazing.
"Coming into this week I didn't really have any expectations. I didn't even think about making the finals or winning it.
"I just tried my best, and I felt very comfortable here.
"Every victory is special, this one even more so because it's been a while since I've won a tournament."