The Spaniard has now won three straight titles, after his Barcelona Open and Monte Carlo Masters victories, while his record on clay this year is 15-0.
Nadal edged the Austrian in the tie-break of a tense first set that lasted one hour and 18 minutes.
He broke world number seven Thiem early in the second set to set up the win.
Nadal will be confirmed as the new world number four, replacing 18-time Grand Slam champion Roger Federer, when the new rankings come out on Monday.
That will improve his seeding for the French Open, which starts on 22 May and where Nadal is a nine-time champion.
Nadal, who beat defending champion Novak Djokovic in the semi-final, has now won his 30th ATP World Tour Masters 1000 title, tying the all-time record with Serbia's Djokovic.
The former world number one was last inside the world's top four in October 2016 and struggled with a wrist injury last year, which forced him to pull out of the French Open and Wimbledon and end his season early.
Nadal told Television Espanola: "The truth is I was up against an opponent who, in the next five to 10 years, will be fighting for the most important titles, so I'm very happy to have won.
"It was a very exciting game.
"It was a very important final for both of us, for him as it was the first in the Masters 1000, and for me it's always special to play here in Madrid, in this unique tournament.
"You never know when it might be the last, so I always try to enjoy it."