During the reign of Emperor Gaozong of Tang, Wang Xiaojie followed Minister of Works Liu Shenli on a campaign against Tubo and was captured in battle. The king of Tubo saw him, wept, and said, "Your appearance greatly resembles my father." Thus he was spared death and soon escaped back to court.
After Emperor Gaozong's death, Empress Wu Zetian declared herself emperor. Knowing that Wang Xiaojie had lived among the Tibetans after being captured and understood their ways, she appointed him commander of the Wuwei Army. Alongside General Ashina Zhongjie of the Left Guard, he led a campaign against Tibet, reclaiming the four garrisons of Kucha, Khotan, Kashgar, and Suyab that had been lost for years. Delighted, Empress Wu promoted Wang Xiaojie to General of the Left Guard, granted him a baron title, and soon made him commander of the Shuofang Circuit. However, after a defeat in a later battle against Tibet, he was stripped of his rank.
Later, the Khitan leaders Li Jinzhong and Sun Wanrong rebelled against the Tang Dynasty. Empress Wu Zetian recalled Wang Xiaojie to serve as commander of the Qingbian Circuit, leading 180,000 troops to suppress the rebellion. The two armies clashed in a valley. Wang Xiaojie led from the front, charging out of the valley to form battle lines for a decisive fight. However, the rear army commander Su Honghui, seeing the enemy's numbers, abandoned his armor and fled. Without reinforcements, Wang Xiaojie accidentally fell into a ravine and died, throwing the Tang army into chaos, with nearly all 180,000 soldiers lost. A survivor named Zhang Shuo returned to Chang'an and reported to Empress Wu, "Wang Xiaojie fought bravely; this defeat was not his fault. It was due to Su Honghui's desertion on the battlefield." Enraged, Empress Wu immediately sent an official to Youzhou to execute Su Honghui. Before the official arrived, he was overtaken by another envoy from the empress, who announced that Su Honghui had redeemed himself by meritorious service in a later battle against the Khitan and had been pardoned from the death sentence.
Later, the idiom "Atone for Crimes by Good Deeds" came to mean performing meritorious acts to compensate for one's offenses.
Source: *Old Book of Tang*, "Biography of Wang Xiaojie"
Meaning of the Idiom: Later, the Chinese idiom "立功赎罪" came to describe performing meritorious acts to compensate for one's offenses.