He hailed from Fanyang 繁陽 (modern Neihuang 內黃, Henan) and was a grandson of Zhang Chang 張敞, with whose son Zhang Ji 張吉 together he was instructed in the Confucian Classics. He was once appointed court gentleman (lang 郞) but soon left this post because of illness and later became a secretary of Wang Shangchu 王商除, Minister of War (dasima 大司馬).
His excellent fulfilment of his duties qualified him for promotion to attendant censor (shi yushi 侍御史). Emperor Ai 漢哀帝 (r. 7-1 BCE) appointed him regional inspector (cishi 刺史) of Liangzhou 涼州. After several years in this position he retired.