Ding appeared to be heading towards a one-sided victory as he claimed the first three frames, only for King’s resilience and a number of unforced errors to cost him in a 5-4 defeat.
After an 81 break put Ding ahead, he doubled the lead when King rattled the jaws of the corner pocket with the final black which would have forced a re-spot following a dogged fight-back.
At 3-0, Ding had several chances to ensure a mid-session whitewash but failed to capitalise before King finally got off the mark.
The momentum continued post-interval as King grinded his way to parity before forcing a decider after Ding had taken frame seven.
King will now face 2005 world champion Shaun Murphy for a place in the quarter-finals.
Also in the second and final session of the day, Murphy eliminated Dominic Dale, winner of the inaugural Shanghai tournament back in 2007, after going the full nine frames.
The ‘Magician’ also cruised into a 3-0 lead, coming close to a maximum break in the second frame, only to catch an unfortunate kiss on the yellow after putting away his 11th red.
Scoring a 107 break in the end, Murphy took a further knock of 41 in the third before the Welshman finished the half-session with a morale-boosting 89 break.
With further runs to 67 and 86, Dale would eventually save two match frames from 4-2 down before Murphy took the decider.
Mark Allen won four frames on the bounce to advance at the expense of 15-year-old Lu Haotian.
The schoolboy scored a break of 52 to take the lead before Allen duplicated the feat en route to tying at 1-1.
Allen again pegged his opponent back before springing into life after the mid-session interval, winning three frames featuring runs to 86 and 45 to progress.
The Northern Irishman will now play either Judd Trump or Barry Hawkins in the second round on Thursday.
Ali Carter held off a Robert Milkins recovery to win their encounter 5-4 and set up his last-16 tie on the very same day with Stephen Maguire, who saw off Peter Ebdon in the earlier session.
Carter built to 66 and 41 on his way to a 2-0 lead in frames only for Milkins to win three in a row to turn the tie around.
And after twice drawing level, this year’s World Championship runner-up won the decider from the final colours to send the 34th-seed packing.
The first round concludes on Wednesday and second-round pairings get underway on Thursday.