He joined Li Hongzhang’s Huai Army as a cavalryman to help suppress the Taiping Rebellion, serving with Liu Mingchuan.
He later helped suppress the Imo rebellion, with his marines arresting Heungseon Daewongun, the father of King Gojong, after arriving at Incheon with a fleet of seven ships.
While in Nagasaki on 13 August 1886, a number of drunken sailors from Zhenyuan became involved in a brawl in a local brothel, during which a Japanese police officer was fatally stabbed.
During the First Sino-Japanese War of 1894–95, Ding pushed for a direct confrontation with the Imperial Japanese Navy, but was ordered by Beijing not to operate east of the mouth of the Yalu River, for fear that China's prized modern warships would be damaged or destroyed.
Ding refused offers of political asylum by Japanese admiral Itō Sukeyuki and committed suicide by an overdose of opium in his office at his Liugong Island headquarters.
At the request of surviving generals in 1911, he was restored to all of his ranks, and his family was able to give him a proper burial in 1912 after the Xinhai Revolution overthrew the Qing dynasty.