Sharapova won her first tournament of the year and clinched the 30th title of her career. She is now undefeated in 13 consecutive matches on the indoor clay in Stuttgart.
Ivanovic wasted a 3-1 lead in the second set as Sharapova raised her game to stay in the high-quality match and finally prevail in a showdown between two former top-ranked players and French Open champions. Ivanovic was seeking her third title of the year.
"I just tried to hang in there," Sharapova said.
Ivanovic got off to a flying a start and won the first five games of the match before Sharapova started fighting back.
Ivanovic wasted a set point and could not serve out the set at love. She gifted Sharapova another game with a double-fault but finally pulled together to win the first set.
Sharapova had trouble reading Ivanovic's varied game and change of pace. But she held on as Ivanovic began to lose her focus.
Sharapova returned late last year after missing four months following shoulder surgery.
"It was a very tough year for me," she said.
Stuttgart is the only tournament Sharapova has won three times.