His family was from Qujiang (曲江) in Shao Prefecture (韶州, roughly modern Shaoguan, Guangdong) in the region called Lingnan 岭南),[3] which was at the time a relatively remote area of the Tang empire.
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).
Zhang Jiuling later passed the jinshi imperial examinations under poet Shen Quanqi 沈佺期 and scored the highest on that occasion.
[citation needed] 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 (中書省, the zhongshu sheng).
[citation needed] In 725, at Zhang Yue's suggestion, Emperor Xuanzong offered sacrifice to heaven and earth at Mount Tai.
Emperor Xuanzong issued an edict praising him for his filial piety, and made him the commandant at Hong Prefecture (洪州, roughly modern Nanchang, Jiangxi).
Soon thereafter, Zhang was made the deputy minister of public works (工部侍郎, Gongbu Shilang) but was put in charge of drafting edicts.
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 allowed to return to mourning.
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 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.
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.
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.
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.