Li appeared to be on course for victory as she stormed into a 6-4, 4-0 lead but 24 unforced errors from the French Open champion allowed Sharapova to take the next six games and the set.
Sharapova then seemed certain to cruise to victory when it began to drizzle. The Russian took a 4-1 lead in the third but Li fought back to win four successive games to take a 5-4 lead.
Both held their serves the rest of the way and the match went into a tiebreak.
After waiting in the changing rooms for two hours because of the rain, the decider was over in five minutes as Li hit into the tramlines, handing Sharapova victory in 2 hours, 52 minutes.
"It was a really difficult match what with so many swings and having to wait an hour or two hours and then a tie breaker in the final," Sharapova said. "It almost feels difficult to have a loser and a winner as it all came down to one game, but I am happy.
"It's great to beat someone at the level she played last year and knowing how well she plays on clay and how she defends and get herself back in good positions."
Sharapova was ahead first in the match as Li hit the ball in the net to hand her the first break. However, Li broke straight back and did so again in the 11th game to take the set.
Li was in control as she broke to love and raced into a 4-0 lead in the second set, at one stage taking 15 points out of 17 as Sharapova struggled to deal with the ferocity of her strokes.
But the pressure seemed to get to Li and her game collapsed as Sharapova went on to win the next eight games.
Li clawed her way back in when she got to 40-0 in the ninth game of the second set but Sharapova broke following a couple of unforced errors and two double faults and went on to successfully serve for the set.
Li managed to come back and level the final set as the rain lashed down in Rome. The match was delayed briefly at 5-5 and the players waited courtside for it to ease up slightly before play resumed.
Sharapova almost gifted the match to Li when an awful mistake saw her smash the ball into the net and hand her opponent a championship point. But Sharapova rescued it with a powerful forehand into the corner.
With the rain continuing to pour down, the players were asked if they wanted to continue. Both said they did, but were eventually forced off court before the tiebreak with the torrential rain turning the clay to mud.
"The match was a joke," Li said. "It's tough to play in such heavy rain and then you go and rest for two hours and then play again in heavy rain... but I still have positive things to take away, she was just stronger and tougher.
Looking ahead, she added: "I liked the way I moved on court and hit the ball — there's a lot of positive things and I think I am ready for the French Open."
Top-ranked Novak Djokovic will have to wait until Monday to defend his title against Rafael Nadal in the men's final. The match has been put back until midday local time (1000 GMT) because of the rain.