Russian Sharapova, a former world number one now ranked ninth, needed to draw on all her experience on the 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 and has not been at her dominant best in 2014 but her form in Madrid suggests she may be a contender at the French Open which starts later this month.
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 at an earlier changeover 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 joins 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.