Trump trailed 8-7 but won three frames in a row to clinch the first prize of £250,000, wrapping up victory with a clearance of 126.
It gives the Bristolian a second Masters success – he beat Ronnie O’Sullivan to claim the title four years ago.
Victory for Williams, who turns 48 in March, would have made the Welshman the oldest ever Masters champion, eclipsing the record of Stuart Bingham, who was 43 years and 243 days old when he won in 2020.
Contesting his first Masters final for 20 years, Williams made the ideal start with a total clearance of 138, but Trump hit back to win the next four frames in succession with the aid of breaks of 61, 106 and 73.
A second century of the match, followed by a break of 60, saw Williams reduce his deficit to a single frame in the first clash between the pair since Trump edged an epic World Championship semi-final 17-16 last April.
However, Williams then badly misjudged an attempted double on a red to the middle pocket early in frame eight and 33-year-old Trump stepped in with an 89 break to stretch his lead to 5-3.
Williams needed three scoring visits to win frame nine but eventually sealed it with a break of 50 to the pink, only for Trump to restore his two-frame advantage in the next following a 66.
Breaks of 80 and 52 helped Williams claim the next three frames in succession as he restricted his opponent to a total of just 35 points, but Trump surprisingly won a 58-minute 14th frame thanks to some sublime safety play on the final red and colours to level the scores.
A superb century edged Williams back in front only for Trump to draw level once again, the left-hander slamming in a double on the last red and then laying a snooker behind the black from which Williams escaped but left the yellow over the corner pocket.
Trump ran out of position on a break of 59 in the 17th frame and allowed Williams in to counter-attack, only for the Welshman to snooker himself behind the pink when trying to get on the penultimate red.
Trump took full advantage and cleared up to move 9-8 in front, before sealing the next frame and victory in style with another century, finished in flamboyant fashion.
The victor said afterwards, before lifting the Paul Hunter Trophy: “This is by far my best ever win. The way I played this week is not my best, this is my best ever performance to grind out and win this.
I should have been out in the first round, should have been out in the second round, should have lost this one— Judd Trump
“Incredible really, I got totally outplayed in the whole game but I was just trying to hang on.
“At 8-7 down I was kind of gone but I managed to win that frame and then I played all right in the last couple of frames.
“I should have been out in the first round, should have been out in the second round, should have lost this one. I’m like a cat!”
Williams said: “It was a great match all the way through. The standard was quite good. Judd made a fabulous break in the last frame…that’s why he’s one of the best in the world. He was a bit too strong for me at the end.
“I’m not a young man anymore but I can still give these youngsters a run for their money!”