The 19-year-old from Essex, hoping to win his first tournament since the British Open last April, appeared to be on his way out as Hamilton compiled breaks of 52, 93, 111, 42 and 71.
The fightback began when O'Sullivan, the former UK champion and second favourite behind Stephen Hendry to collect the £32,500 first prize on Sunday, fired in a 105 break in frame six.
By now O'Sullivan, always one of the most positive players on the circuit, was intentionally throwing caution to the wind.
"Playing a lot of safety did me no good so if I had a pot on I went for it," O'Sullivan said. "I decided to change my tactics and play with a carefree attitude."
O'Sullivan won frame seven after a fluke on a pink when he was clearing up and he forced a decider with a 75 break in frame eight.
Hamilton was then presented with a golden chance, but one error proved costly. Holding a 20-point advantage, he missed a simple black and O'Sullivan took the match with a run of 48.
Steve Davis, the defending champion, survived to the last eight of a ranking event for only the second time in five attempts this season after a 5-3 victory over Mark Williams.Reuse content