Zhang Fang was born in a poor family in Sima Yong's princely fief, Hejian commandery.
The intent was to make Ai complicit in the two princes' rebellion so that Jiong would execute him first before they attack the capital, thus eliminating a potential political rival.
However, the plan did not go as expected, as Ai managed to fight back and kill Jiong, taking over the imperial court.
Ai sent his general Huangfu Shang (皇甫商) to stop Zhang's advances, but he was defeated in a surprise attack.
He had slave women from noble families to grind up food for his men and implemented forced labour indiscriminately as a punishment for those who he found were not partaking in the campaign hard enough.
[9] The Zizhi Tongjian further claims that, to keep his army supplied, he also had people killed and mixed their flesh with beef and horse meat.
The generals within Luoyang, Shangguan Si (上官巳) and Miao Yuan (苗願) retaliated against Zhang Fang but were defeated.
[11] Wang Jun decisively defeated Sima Ying at Ye, and he barely escaped with his remaining officials before making his way towards Luoyang.
He wanted to move the emperor to Chang'an and make the city the new capital seeing that his men were becoming restless staying in Luoyang.
He justified to the emperor that he only wanted him to inspect the ramparts he had built years ago to ensure that the defenses are proper.
[13] Meanwhile, while the emperor was at the rampart, Zhang Fang's soldiers raided the palace and looted the place until there was none left to steal.
Zhang then considered burning down the palace and Ancestral Temple to prevent anyone else from entering but forfeited the decision after his contemporary, Lu Zhi, compared his actions to Dong Zhuo.
After they were moved, Sima Yong appointed Zhang as General Who Leads The Army of the center, chief of affairs of the Masters of Writing, and acting Administrator of Jingzhao.
However, Zhang Fang greatly opposed it, ostensibly pointing out Yong's advantages when in reality, he knew that peace would result in his execution for his crimes.
Sima Yong summoned an old friend of Zhang Fang named Zhi Fu (郅輔) who he sent to assassinate the general.