Russian Sharapova, a former world number one, needed to draw on all her experience on clay in the Spanish capital to see off the 22-year-old Romanian fourth seed, who was appearing in the final of a premier event for the first time.
Sharapova missed the second half of last season with a shoulder injury but her form suggests she may be a contender at the French Open which starts later this month.
By winning in Madrid, where she was runner-up last year to top-ranked American Serena Williams, Sharapova is projected to climb to number seven in the world when the rankings are updated on Monday.
"I don't take these moments for granted because I know what it's like to be out and injured and trying to find your way back just to play tennis," she told a news conference.
"I like the work that I put in and I want to get the opportunities to be in the final," added the 27-year-old, one of the best-paid athletes in sport who has her own clothing lines and a company that sells candy called Sugarpova.
"So it doesn't matter if I'm playing on the moon or in Madrid, to be in the final position is an honour."
Sharapova, the 2012 Roland Garros champion had shown glimpses of her best on her run to the final but looked all at sea in the early stages against a fired-up Halep, who attacked the Russian, five years her senior, at every opportunity.
The match was a clash of two very different styles, with the rangy Sharapova, her shrieks echoing around the Magic Box arena every time she struck the ball, relying on power and the stocky Halep a bundle of energy scurrying around the court.
Halep quickly opened a 4-0 lead before Sharapova finally managed to hold in the fifth game after saving another break point.
Some courtside advice from her coach to up her speed and try to hit the corners did not appear to have helped, however, as Halep broke again in game seven to secure the set.
Before Sunday, Sharapova had dropped the opening set 24 times in finals and fought back to win seven times and she changed the tone of the match with a break of the Halep serve in the opening game of the second set.
After breaking again and serving out the set, Sharapova grabbed another break for a 2-1 lead in the decider and recovered from another wobble to claim her third victory in as many matches against the young pretender.
With nine clay titles, she joined Venus Williams as the third most successful active player on the surface, one behind Spaniard Anabel Medina Garrigues and Serena Williams who each have 10.
Halep said she had no regrets as she had learned a great deal from what she called "an amazing week" in the Spanish capital.
"I played really well all week and I beat top layers and I had a very high level of my tennis," she told a news conference.
"Maria is a great player and a great champion. She played really well, and I think she deserved to win this title.
"The different I think is the experience. She has more experience than me."
- Sports & Recreation
- Serena Williams