The former world number one will face off for the title, at the last major tune-up prior to the US Open, when she plays Serena Williams on Sunday.
The American top seed Williams moved within one win of a second pre-Open hardcourt title as she beat Caroline Wozniacki 2-6, 6-2, 6-4.
Ivanovic led by a set and 5-2 but fell victim to nerves as the scrambling Sharapova, a five-time grand slam champion and fellow former number one, fought back. Sharapova levelled the sets at one each as she clinched the second set with an ace.
Ivanovic had to be seen by the doctor in the third set. The Serb suddenly stopped at 15-all in the second game. She went to the sidelines and lay down for a few moments to receive treatment and then the match continued.
Sharapova's frustration level appeared to grow as the Russian struggled to get a grip on a game which produced seven double-faults in the third set.
"It was just a matter of a couple points," Sharapova said. "There were certainly a lot of ups and downs. I wasn't happy with that."
Ivanovic saved a pair of Sharapova match points and finally held for five-all.
Ivanovic broke two games later to secure the emotional win with a backhand cross-court winner on second match point.
- Sharapova 'a fighter' -
"Up a set and 5-2, I got tight," said Ivanovic. "I was not moving my feet. She's a great champion and she used her opportunities.
"It was very important for me to get my composure back in the third set.
"My emotions were all over the place. There were a lot of breaks in the final set. Maria is a fighter and never gives up. But I stayed calm.
"It was hot and humid and I felt sick in the second set. But the tablets I got from the doctor worked and I feel better now."
Ivanovic and Williams will play for the fourth time this season, with the Serb earning a win at the Australian Open.
"It will be a very tough one, but first comes recovery," said Ivanovic. "It is fun to play her and test yourself against the best. It will be a quick turnaround."
Williams, who claimed her 61st career WTA title at Stanford two weeks ago, is playing a third tournament in a row for the first time since late 2007. She improved her 2014 match record to 37-6 with the win over Wozniacki.
The 32-year-old said that she needed a set to find her game after a slow start.
"I got off to a little bit of a slow start, but I was definitely in it," said Williams, who followed up her win in Stanford by reaching the semi-finals last week at Montreal, where she lost to her sister Venus. "I had to get out there and grind out everything."
Wozniacki came to the match after beating two top 10 players in a row for first time since the 2010 WTA Finals.
Despite the defeat, Wozniacki is ready for one last US Open tune-up next week in New Haven.
"I've had a lot of matches these couple of weeks," said the 24-year-old Dane. "But I'm good with playing New Haven. I'm going to use it as even better preparation."