Making up for her loss in last year's final to Petra Kvitova, the clay court triumph ensured the Dutchwoman Bertens will move to a career-best fourth in the world rankings.
Bertens came back from 4-2 down in the first set against French Open champion Halep by winning the next three games, striking the first blow in a gripping final full of drama which lasted one hour and 27 minutes.
'She's not afraid' - How Raducanu 'transcends crowd and gets them on her side'
Bertens, who hit four aces among her 25 winners in an excellent performance, got off to an ideal start in the opening game of the second by breaking Halep, who was playing in her third Madrid final after triumphs in 2016 and 2017.
The Romanian stayed in contention but was dealt a terrible dose of luck in the eighth game which handed more momentum to Bertens.
A shot from Bertens was heading way out and would have handed Halep two break points but the wayward ball struck the Romanian's body, earning her opponent a fortuitous point that eventually led to her holding serve.
Bertens earned her first championship point with a scorching ace but Halep saved it with a drop volley at the net, only to then hand her rival another one by finding the net with a careless shot.
Bertens missed out again but earned a third championship point when Halep narrowly missed the baseline and she finally seized her ninth WTA title when the world number two hit a backhand out.
It was Bertens' fourth victory over a Grand Slam winner during the week on her way to the title.
"At the beginning I was a little bit searching for my game still, but I think the rest of the match I played really solid, really smart," Bertens told a news conference.
"Maybe a little bit lucky like on the 4-3 game when I hit the ball in the fence and it hit her but sometimes you need a little luck. I'm just happy how I was able to finish the match."
"I just feel really happy. I am really proud of this week. I played some good tennis and will be number four in the world on Monday, it is just all amazing things," Bertens added.
Halep had no complaints, congratulating her opponent while admitting she played into Bertens' hands.
"She played better tennis tonight. She deserved to win the match, definitely," she said.
"I think I played wrong, and I'm upset about that. I played stupidly today, I did everything that she liked. It was a good match from her. And she deserved to win the title because she played really good tennis throughout the whole week."
Svitolina - Halep - US Open Highlights
Svitolina downs Halep to reach US Open quarter-finals