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.
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.