His great-great-grandfather Zhang Hao served as Minister of Works and his great-grandfather Zhang Gang as Administrator of Guangling, and both were known for their names and deeds. When Liu Bei pacified Yi Province and took the post of Governor of Yi Province, Zhang Yi became an Assistant Clerk. At the end of the Jian'an era he was recommended as Filial and Incorrupt (xiaolian) and became Chief of Jiangyang County; he was transferred to be Prefect of Fuling, promoted to Administrator of Zitong, and through successive promotions rose to Administrator of Guanghan and then of Shu Commandery. Records, Shu 15 §11–12
In the 9th year of Jianxing (231) he became Area Commander of Laixiang and General of the Household Who Pacifies the South (suinan zhonglang jiang). Being strict by nature in upholding the law, he failed to win the goodwill of the non-Han peoples with their different customs, and when the tribal chief Liu Zhou turned against him and rose in revolt, he raised troops to suppress him. The Biography of Ma Zhong records that when Liu Zhou rebelled in the 11th year of Jianxing (233), the court recalled Zhang Yi and replaced him with Ma Zhong. Records, Shu 15 §12Records, Shu 13 §31
When he was recalled before he had defeated Liu Zhou, his subordinates said he should ride back at once to accept punishment. Zhang Yi said that he was returning only because he had failed in his duty when the barbarians stirred, but that his successor had not yet arrived and he was on the battlefield, so he ought to transport provisions and stockpile grain as the means to destroy the rebels; being dismissed was no reason to abandon the affairs of the state. He kept command without slackening until his successor arrived, and when Ma Zhong wiped out Liu Zhou on the foundation he had laid, the Chancellor Zhuge Liang heard of it and thought well of him. Records, Shu 15 §12–13
When Zhuge Liang marched out to Wugong, he made Zhang Yi Commander of the Front Army (qianjun dudu) and concurrently Administrator of Fufeng. After Zhuge Liang's death Zhang Yi became Leader of the Front Army (qian lingjun), and his merit in suppressing Liu Zhou was belatedly recognized with the rank of Marquis Within the Passes. In the 1st year of Yanxi (238) he entered the court as Master of Writing (shangshu), and gradually moved on to command at Jianwei; he was granted the tally (jiajie), raised in fief to Marquis of the Capital District (duting hou), and became General-in-Chief Who Conquers the West. Records, Shu 15 §13–14
In the 18th year of Yanxi (255) he returned to Chengdu together with the General of the Guards, Jiang Wei. When Jiang Wei proposed another campaign, Zhang Yi alone argued against it at court, saying that the state was small and the people weary, so arms should not be used recklessly. Jiang Wei would not listen, took Zhang Yi and others with him on campaign, and raised Zhang Yi to General-in-Chief Who Guards the South. When Jiang Wei crushed Wang Jing, Wei's Inspector of Yong Province, at Didao, and Wang Jing's men who died in the Tao River were counted in the tens of thousands, Zhang Yi said that it was time to stop, for advancing further might ruin this great achievement. Jiang Wei was furious, and in the end he besieged Wang Jing at Didao but could not take the city. Records, Shu 15 §15–16
From then on Jiang Wei was privately on bad terms with Zhang Yi, yet he always took him along, and Zhang Yi, having no choice, went with him. In the 2nd year of Jingyao (259) he was transferred to General of Chariots and Cavalry of the Left and concurrently made Inspector of Ji Province. The Biography of Liao Hua records that Liao Hua's rank was equal to Zhang Yi's. Records, Shu 15 §16 · 24
In the 6th year of Jingyao (263), when Wei raised a great army, Jiang Wei had earlier memorialized that Zhang Yi and Liao Hua should be sent to guard the mouth of Yang'an Pass and the bridgehead at Yinping, but Huang Hao had the matter shelved. Only after Zhong Hui and Deng Ai had advanced did the court send Liao Hua to Tazhong, and Zhang Yi, General of Chariots and Cavalry of the Left, Dong Jue, General-in-Chief Who Supports the State, and others to the mouth of Yang'an Pass. When the pass had already fallen, Zhang Yi and Dong Jue joined Jiang Wei and Liao Hua, fell back to Jiange, and held off Zhong Hui. Records, Shu 14 §43–45Records, Shu 3 §43Records, Wei 28 §105
After the Later Sovereign, Liu Shan, surrendered to Deng Ai, Zhang Yi went with Jiang Wei to Fu County and surrendered to Zhong Hui. The names of Jiang Wei, Zhang Yi, Liao Hua, Dong Jue and others also appear in a report Zhong Hui submitted. In the 1st month of the following year (264) he accompanied Zhong Hui to Chengdu and was killed there by mutinous soldiers. Records, Shu 15 §16Records, Wei 28 §115
In his assessment, Chen Shou named Zhang Yi together with Deng Zhi and Zong Yu, and said that Zhang Yi's standing up to Jiang Wei's keen drive was praiseworthy. Records, Shu 15 §85