Heading into the final session with a 6-3 lead the 43-year-old Englishman looked in fine form after a 131 break in the final frame of the afternoon.
However, his gritty opponent hit back in the evening session, taking six of the next eight frames to move to within one of victory.
'A special place in sport' – Why World Championship must stay at Crucible
O'Sullivan was not finished though and won the penultimate frame to set up a decider.
And it was then that his class shone through, a century securing a dramatic victory.
"We both didn't play great," said O'Sullivan.
'I was lucky'
"I'm just pleased to be competing. My main goal is to come out here and enjoy it, play with freedom.
It's just a game. It's nice to still be playing.
"It's a great venue, great tournament, great crowd. If everyone's enjoyed it, then great.
"We want to perform and play the best we can.
"I was lucky today - that double there, I got away with it."
Has any pool player conquered snooker? Trump set to take plunge in Atlantic City
Who does Stuart 'Ball-Run' Bingham rate the snooker GOAT?