Shelton had 11 aces on the way to becoming the youngest player to win this event since Andy Roddick lifted the trophy at 19 years old in 2002.
Shelton, 21, has had his issues on clay courts.
He was 2-7 in his career on the slower surface and had lost his last five clay-court matches before this week's tournament.
But Shelton survived a trio of three-set matches to take the title - his first since winning in Tokyo in October.
Second ATP Tour trophy in the bag ✅— ATP Tour (@atptour) @BenShelton | @mensclaycourt | #USClay pic.twitter.com/EXzxux2XF1April 7, 2024
Shelton won 83 per cent of his first-serve points to triumph after two hours, 16 minutes.
He and Tiafoe are friends who had kind words for each other after the match.
"I know this one stings," Shelton said.
"Sorry you didn't go back-to-back titles, but you're that type of player who can go back-to-back. I want to see you do it again this year."
Tiafoe said it was great playing in a final after a difficult start to the year.
"It would have been cool to get number four," he said of his bid to add to previous tournament wins at Delray Beach, Stuttgart and in last year's Men's Clay Court Championship in Houston.
"We'll get that soon enough. Let's really build on this and let's have a good '24."
Shelton is expected to rise to No.14 in next week's rankings.
In Marrakech, Italy's Matteo Berrettini surged to his first ATP Tour title since 2022 with a 7-5 6-2 victory over Roberto Carballes Baena.
The former world No.6 managed two breaks in each set as he took the title in one hour 46 minutes.
Berrettini in control 💪— ATP Tour (@atptour) @MattBerrettini wins 5 points in a row to claim the opener against Carballes Baena 7-5!#GrandPrixHassanII pic.twitter.com/sF2iMXByn0April 7, 2024
"It's been a tough past couple of years, I would say, and thanks to (my team) I was able to overcome all the tough moments," the Italian said in his court-side interview.
Poland's Hubert Hurkacz will rise to a career-high world ranking of No.8 after winning the Estoril Open final 6-3 6-4 against Pedro Martinez of Spain.
Hurkacz sent down 15 aces during his one hour, 27 minute triumph.
"I'm so happy with my performance today," he said.
"I'm proud that I found my serve and that definitely helped me a lot.
"Pedro is such a great competitor ... I needed to play really great tennis to compete with him and fortunately I did it."