O'Sullivan had led 7-1 after the afternoon's opening session, but his glory procession was put on hold as Ding took the first two frames of the evening with centuries.
But the Chinese star missed a golden chance in the next and slipped 8-3 down.
The mid-session interval was due, but the players agreed to play one more frame with the finish line in view - and O'Sullivan produced a staggering clearance to claim the match.
"I knew it was on when I got to 48 and I split the reds, and they were perfect," said O'Sullivan of his amazing maximum - which he finished off in typical style by playing the final black left-handed.
"For a few balls I concentrated on just winning the frame, but when I got to 60, 70 or whatever, I knew I had to go for it."
In the afternoon session the world champion rattled through the opening three frames, producing breaks of 91 and 70 as he did so.
It looked like turning into four on the trot as O'Sullivan rattled into a 49-0 lead in the next frame, but Ding clawed his way back into the match and edged what turned into a thrilling frame on the black.
Ding then made 55 in the next, but fell short of the line - and this time it was O'Sullivan's turn to pinch one as he went into a 4-1 lead.
A 92 in the next made it 5-1, but that was the last 50+ break of the match as the final two frames turned into tense, error-strewn affairs - both of which saw O'Sullivan come out on top.
O'Sullivan's stunning performance means that he will be a red-hot favourite to retain his World Championship crown later in the year - and, should he do so, he will take yet another step to establishing his credentials as the greatest player ever to hold a cue.
- Sports & Recreation