Zhang Jiuling was born in 678, during the reign of Emperor Gaozong. His family was from Qujiang (曲江) in Shao Prefecture (韶州, roughly modern Shaoguan, Guangdong), which was at the time a relatively remote area of the Tang empire. His family traced its ancestry to the Jin Dynasty (265-420) chancellor Zhang Hua, and his First Son (張祎). His great-grandfather Zhang Junzheng (張君政) served as the secretary general of Shao Prefecture, and therefore settled there. His grandfather Zhang Zizhou (張子冑) served as a county magistrate, and his father Zhang Hongyu (張弘愈) served as a county secretary general.[1]

Zhang Jiuling was said to be intelligent in his childhood and capable in literary skills. In 685, when he was 12, he had an occasion to write a letter to Wang Fangqing, then the prefect of Guang Prefecture (廣州, roughly modern Guangzhou, Guangdong). Wang was impressed and commented, "This child will do great things in the future." When the official Zhang Yue was exiled to the region,[2] he met Zhang Jiuling and was impressed, and treated Zhang Jiuling with kindness. Zhang Jiuling later passed the imperial examinations and scored the highest on that occasion. He was made a Xiaoshu Lang (校書郎), a clerk at the imperial institute Hongwen Pavilion (弘文館). Later, while Li Longji was crown prince under his father Emperor Ruizong (r. 710-712), he summoned those in the empire known for their literary talent and personally examined them. Zhang scored the highest on this occasion as well, and was made You Shiyi (右拾遺), a consultant at the legislative bureau of government (中書省, Zhongshu Sheng).[3]

In 712, Emperor Ruizong passed the throne to Li Longji, who took the throne as Emperor Xuanzong. For some time, though, Emperor Xuanzong did not sacrifice to heaven and earth outside of the capital Chang'an, as was customary for emperors. Zhang Jiuling submitted a petition asking him to carry out such sacrifices, and Emperor Xuanzong, following his advice, did so. In or around 713, he submitted a petition to the chancellorYao Chong, pointing out the importance of a clean and fair civil service system, and Yao was impressed.

Zhang became known for his talent in understanding people's talents. At that time, Emperor Xuanzong had him and his colleague Zhao Dongxi (趙冬曦) decide the postings for the people selected for official service by the ministry of civil service affairs, and he and Zhao were considered fair and capable in finding the right posts for people. In 722, he became Sixun Yuanwailang (司勳員外郎), a low level official at the ministry of civil service affairs. At that time, Zhang Yue was a chancellor as Zhongshu Ling (中書令, the head of the legislative bureau), and he considered Zhang Jiuling, as they had the same family name, like a brother, often stating, "He will surely be the most distinguished poet." Zhang Jiuling was also happy that Zhang Shuo appreciated his talent, and therefore became a follower of Zhang Yue's. In 723, he was made a Zhongshu Sheren (中書舍人), a mid-level official at the legislative bureau, serving under Zhang Yue.

In 725, when Emperor Xuanzong, at Zhang Yue's suggestion, sacrificed to heaven and earth at Mount Tai. After the ceremony, many of the officials that Zhang Shuo favored were to be promoted to high positions. Zhang Yue had Zhang Jiuling draft the edict for the promotions, and Zhang Jiuling, knowing that such promotions will draw resentment from others, tried to dissuade Zhang Yue, but Zhang Yue insisted, causing much resentment against Zhang Shuo. In particular, Zhang Jiuling warned Zhang Yue about the minister Yuwen Rong, whom Zhang Shuo did not respect but whom Emperor Xuanzong favored for his talent in gathering money for the imperial treasury. Zhang Yue did not believe Yuwen Rong could do him harm, but in 726 was removed after accusations by Yuwen. In the aftermaths, Zhang Jiuling was made the deputy minister of worship (太常少卿, Taichang Shaoqing) -- an honored post without much actual authority—and soon was made the prefect of Ji Prefecture (冀州, roughly modern Hengshui, Hebei). Zhang, because his mother was then old and at home in Shao Prefecture, requested to be posted to a prefecture south of the Yangtze River, so that he could better communicate with her. Emperor Xuanzong issued an edict praising him for his filial piety, and made him the commandant at Hong Prefecture (洪州, roughly modern Nanchang, Jiangxi). Zhang was later made the commandant at Gui Prefecture (桂州, roughly modern Guilin, Guangxi) and the examiner of Lingnan Circuit. Emperor Xuanzong further made his brothers Zhang Jiuzhang (張九章) and Zhang Jiugao (張九皋) prefects in the region as well, so that the brothers could all visit their mother on holidays.

Meanwhile, Zhang Yue was no longer chancellor, but was still the head of the imperial institute Jixian Institute (集賢院). He often recommended Zhang Jiuling for his talent. After Zhang Yue died near the new year 731, Emperor Xuanzong remembered Zhang Yue's recommendations and recalled Zhang Jiuling to serve as Mishu Shaojian (秘書少監), the deputy head of the Palace Library, as well as a scholar at Jixian Institute, acting as its head. At that time, it happened that an edict needed to be issued to the vassal kingdom Balhae, but no one could write one well. Emperor Xuanzong had Zhang draft one, and it was written quickly. Soon thereafter, Zhang was made the deputy minister of public works (工部侍郎, Gongbu Shilang) but was put in charge of drafting edicts. He was then made Zhongshu Shilang (中書侍郎), the deputy head of the legislative bureau. In 732, his mother died, and he returned to Shao Prefecture to observe a period of mourning for her.

Around the new year 733, Emperor Xuanzong removed then-chancellors Xiao Song and Han Xiu from their chancellor positions, and named Pei Yaoqing and Zhang to replace them—ordering Zhang to end his period of mourning, which was to last for three years, early, making him Zhongshu Shilang but with the chancellor de facto designation of Tong Zhongshu Menxia Pingzhanshi (同中書門下平章事). After Zhang subsequently arrived at the eastern capital Luoyang, where Emperor Xuanzong was at the time, he requested that he be allows to return to mourning. Emperor Xuanzong rejected the request.

Later in 733, Zhang proposed that private citizens be allowed to mint money. With opposition from Pei and Liu Zhi, however, Emperor Xuanzong rejected the proposal. Later that year, Zhang was made Zhongshu Ling and continued to serve as chancellor. Other projects that Zhang proposed included reestablishing the offices of examiners of the 10 circuits and also rice farming in the prefectures just south of the Yellow River, which ended in failure. Zhang was further said to be impatient and easily angered, damaging his reputation. However, Zhang was also said to be honest and always seeking to correct the emperor's behavior, even if it offended the emperor. For example, in 735, after the general Zhang Shougui (張守珪) scored a major victory over the Khitan, Emperor Xuanzong wanted to reward Zhang Shougui by making him a chancellor, but Zhang Jiuling pointed out that it was inappropriate to use the chancellorship as a reward, even with just the honorable title and no actual authority (as Emperor Xuanzong considered as well) and that giving Zhang Shougui the chancellorship for defeating the Khitan meant that there would be no other available awards if he were to defeat the Xi and the Eastern Tujue as well. Emperor Xuanzong agreed and did not give Zhang Shougui the chancellorship. Also in 735, Zhang Jiuling was given the honorific title Jinzi Guanglu Daifu (金紫光祿大夫) and created the Count of Shixing. Zhang was also known for his firm friendships with the officials Yan Tingzhi (嚴挺之), Yuan Renjing (袁仁敬), Liang Shengqing (梁升卿) and Lu Yi (盧怡), despite his later taking higher positions than they did, drawing much praise for his commitment to friends.

In 736, after Zhang Shougui suffered a loss because his subordinate An Lushan failed to follow orders, Zhang Shougui, not wanting to kill An but not wanting to release him for fear of losing authority, sent An to Chang'an, asking the emperor to decide the punishment. Zhang Jiuling submitted the suggestion to have An executed, stating:

Tian Rangju [(a famous general of Qi)] executed Zhuang Jia [(莊賈, the favorite official of the Qi ruler Duke Jing of Qi at that time)] and Sun Wu executed the king's concubine, both for failing to follow military orders. If Zhang Shougui is to have good military discipline, An Lushan must be executed.

He also argued that he believed that An had the temperament to commit treason and would surely do so in the future, but Emperor Xuanzong did not agree. Emperor Xuanzong was impressed by An's military talent and ordered that he be reduced to commoner rank and be allowed to stay in the army.

September 14, 736,[4] was Emperor Xuanzong's birthday, and the princes and the dukes all offered jeweled mirrors as gifts. Zhang Jiuling, believing that the best way to reflect on oneself was to look at others, wrote a five-volume work, calling it the Golden Mirror Records for a Thousand Years (千秋金鑑錄 -- "a thousand years" being an oblique reference to wishing the Emperor a long life, on his birthday), discussing historical examples of rulership, and offered it to Emperor Xuanzong as his gift. Emperor Xuanzong issued an edict thanking and praising him.[5]

By 736, however, fellow chancellor Li Linfu was beginning to gain favor at the expense of Pei and Zhang, who were friendly with each other. At that time, there were several incidents for which the blunt Zhang had offended either Emperor Xuanzong—who was described to have begun to tire of governance and started seeking luxuries in earnest—or Li Linfu, who was described to be ingratiating the emperor:

In fall 736, when Emperor Xuanzong was at Luoyang, he had set to return to Chang'an on March 7, 737.[6] However, at that time, an incident occurred where there were strange apparitions appearing in the Luoyang Palace, and Emperor Xuanzong did not want to stay at Luoyang. On or right before November 9, 736,[7] he summoned the chancellors to ask them whether he could depart for Chang'an immediately. Pei and Zhang, pointing out the fact that it was harvest season and that the imperial train would interfere with harvest, requested a one-month delay. After Pei and Zhang exited, however, Li Linfu remained personally and stated his agreement with the departure, arguing that the farmers could be compensated by relieving their taxes. Emperor Xuanzong was pleased and immediately departed for Chang'an.

Emperor Xuanzong was, then, impressed with Niu Xianke, the military governor (jiedushi) of Shuofang Circuit (朔方, headquartered in modern Yinchuan, Ningxia), wanted to make him the minister of defense. Zhang, who pointed out that Niu was not well-learned and had started from the ranks of low-level administrators—contrary to the Tang tradition of going through the imperial examinations—opposed, and then further opposed the creation of a title. Eventually, despite Zhang's opposition, Emperor Xuanzong, with concurrence from Li LInfu, created Niu the Duke of Longxi.

Li Linfu was associating with Emperor Xuanzong's favorite concubine Consort Wu and trying to have Emperor Xuanzong make her son Li Mao (李瑁) the Prince of Shou crown prince to replace Emperor Xuanzong's then-crown prince Li Ying, who had long lost Emperor Xuanzong's favor. With Zhang strenuously opposing such a move, Li Ying remained in his position.

The deputy minister Xiao Jiong (蕭炅), whom Li Linfu recommended, was demoted on the suggestion of Zhang and Zhang's friend Yan Tingzhi, who further offended Li Linfu by refusing to meet with him. Soon thereafter, there was an incident where Wang Yunyan (王元琰), the husband of Yan's ex-wife, was accused of corruption. Yan tried to intercede on Wang's behalf, and this was discovered.

Li Linfu thus made accusations to Emperor Xuanzong that Zhang and Pei were engaging in factionalism. Around the new year 737, Emperor Xuanzong removed Pei and Zhang from their chancellor posts, making them Chengxiang (丞相) -- the heads of the executive bureau (尚書省, Shangshu Sheng) instead. Niu was made chancellor to replace them, serving with Li Linfu. This was often viewed by traditional historians as the turning point of Emperor Xuanzong's reign, which up to that point was considered a golden age in Chinese history, toward a path of degeneration. The Song Dynasty historian Sima Guang, in his Zizhi Tongjian, for example, commented:[5]

Of the chancellors that the Emperor commissioned after he took the throne, Yao Chong emphasized flexibility, Song Jing emphasized the rule of law, Zhang Jiazhen emphasized administrative abilities, Zhang Shuo emphasized literary talent, Li Yuanhong and Du Xian emphasized frugality, and Han Xiu and Zhang Jiuling emphasized honesty. All of them had their different talents. After Zhang Jiuling was demoted, however, the officials were all concerned about keeping their positions, and honest words no longer had a place in government.

In 737, the imperial censor Zhou Ziliang (周子諒) submitted an indictment against Niu, arguing that Niu should not be chancellor because he lacked talent to be chancellor, and further citing prophecies that appeared to indicate that someone named Niu would usurp the throne. Emperor Xuanzong was incensed, and had Zhou caned and exiled—and Zhou died shortly after departing Chang'an. Li Linfu then submitted an accusation against Zhang, pointing out that Zhang had recommended Zhou. Zhang was therefore demoted to be the secretary general at Jing Prefecture (荊州, roughly modern Jingzhou, Hubei). However, even after Zhang's demotion, Emperor Xuanzong still remembered his honesty, and when officials were recommended, he would often make the inquiry, "How does their honesty compare to Zhang Jiuling?" Zhang died in 740, while on a vacation in Shao Prefecture to visit his parents' tomb, and was given posthumous honors.

After An, then a powerful military governor (jiedushi), rebelled against Emperor Xuanzong's rule in 755, Emperor Xuanzong was, in 756, forced to flee to Jiannan Circuit (劍南道, roughly modern Sichuan and Chongqing) and pass the throne to his son Emperor Suzong. Remembering Zhang's warnings about An, issued an edict further posthumously honoring Zhang and sent messengers to Shao Prefecture to offer sacrifices to Zhang.

^That Zhang was a consultant at the legislative bureau was per his biography in the Old Book of Tang. HIs biography in the New Book of Tang indicated that he was a Zuo Shiyi (左拾遺) -- a consultant at the examination bureau (門下省, Menxia Sheng). Compare Old Book of Tang, vol. 99Archived April 19, 2008, at the Wayback Machine with New Book of Tang, vol. 126Archived 2009-02-02 at the Wayback Machine.