Ding claimed the next and although Day's 62 looked to have taken the match to a decider, he ran out of position to give the Chinese player the chance to seal victory.
Defending Olympic champion Park Ta-Hwan was leading at the final turn, but the 20-year-old Sun surged past his South Korean rival in the final length to seal a place in Chinese Olympic history.