O’Sullivan went into the final session trailing 10-6 but he produced some early magic to cut the deficit to 11-9.
A tournament high-break of 146 allowed him to win three of four frames but his Chinese opponent showed no signs of letting up.
The duo shared the next two frames before Ding scored 117 to book his semi-final spot against Mark Selby.
Speaking after his defeat, O’Sullivan wished his opponent well and he was full of praise for Ding.
The 41-year-old said: “It was a fantastic match and I am really pleased to be involved. I really enjoyed it. I would rather lose a good match than win an awful one.
“Ding is a special lad, a beautiful guy. He is all good; he doesn’t have a bad bone in his body. He wants to win this title so bad. He is in a great place and I wish him all the best.”
Arsenal have reportedly held talks with Dennis Praet's agent and could make a £22million move for the Sampdoria midfielder this summer.
Gareth Bale could leave Real Madrid this summer despite proving to be the match-winner during Saturday's Champions League final.