The Chinese world No. 16 was without a Triple Crown trophy in eight years but beat Ronnie O'Sullivan on his way to the final and the 32-year-old produced another brilliant display to halt an in-form Maguire.
"I was worried about not doing well and asked myself if I could win again," said Ding.
"And the answer was always no but this week I was so confident and played so well and beat [O'Sullivan] on the way which gave me huge confidence and I started to believe I could win the trophy again.
I can't believe I can play like that. It's a big win.
‘Listen to the crowd!’ – The moment Ding won UK Championship
Maguire, gracious in defeat, was delighted with a "great week" in York and praised his conqueror.
"Every time you let him in he scores 100," he said. "I told him a couple of frames ago 'it's not darts we're playing, it's snooker'. It's tough to get in when his safety is good as well.
I've had a great week. The Barbican has been great, York's been great, the crowd were unreal and I've competed with the best.
Ding raced into a 4-0 lead in the afternoon session, capitalising on an error-strewn opening by his opponent and producing some fine snooker himself with breaks of 56, 105 and 128.
But Maguire rallied and reeled off three frames of his own and even threatened to seize an unlikely leveller ahead of the interval, but Ding - who looked nervy in the face of Maguire's comeback - rallied to take the eighth frame and steal a 5-3 lead.
Ding Junhui: 'I’ve done nothing for two years!'
Maguire landed an excellent pot coming off the break, but missed a more routine red to open up the frame for Ding who only needed one visit to the table to extend his lead, hitting a break of 83.
Ding then strung together a run of 45, but gave the table back to Maguire who landed a brilliant red and hit back with a 53 break. But a pressure red miss when it really mattered gave Ding the frame.
Maguire stopped the rot with a huge stroke of fortune, missing a long red only to see the ball bounce up and down the table before hitting another red into the pocket. And that fluke was enough to send him on his way to a century that looked like spurring him on to another frame.
Fluke of the tournament? Maguire makes ridiculous round-the-table plant
But Ding was resilient, and despite some brilliant snooker by Maguire including a marvellous long pot at the start of the frame, Ding made no mistake when he returned to the table and hit a brilliant break of 67.
Maguire return from the mid-session interval with a century after Ding missed easy black gifting the frame. And Ding was again culpable as nerves got the better of him, missing a simple red and once again leaving an open table for Maguire to sweep up with another century to go within two.
But Ding bounced back with a wonderful break of 131 to go within one frame of the championship.
He made no mistake, seizing his first opportunity at the table and closing out the title with his fourth century of the match and taking £200,000 in prize money.