In 806, when Yuan Zhen was 27, during the reign of Emperor Dezong's grandson
Emperor Xianzong, Yuan underwent a special imperial examination before Emperor Xianzong dealing with strategic thinking, and when the list of 18 examinees who passed the examination was announced, Yuan was ranked first — in a group that included such individuals as
Bai Juyi, Dugu Yu (),
Xiao Mian, and Shen Chuanshi (). As a result, Yuan was made
You Shiyi (), a junior advisor at the legislative bureau of government (). Yuan had an outspoken personality, and after being put into an advisorial post, he started submitting suggestions to Emperor Xianzong. In particular, because the officials
Wang Shuwen and
Wang Pi, who dominated the court of Emperor Xianzong's father
Emperor Shunzong — who had previously served as Emperor Shunzong's staff members while Emperor Shunzong was
crown prince — were at that time denounced as frivolous and power-hungry, Yuan submitted an essay detailing what he saw as qualifications that the crown prince's and other imperial princes' staff members should have, and Emperor Xianzong was impressed upon reading it. Yuan further submitted proposals involving the defense of the northwestern borders with the
Tibetan and
Uyghur Empires. Emperor Xianzong, in response, summoned him and requested opinions on strategies to take there. As a result, though, the ruling officials at the time were jealous of Yuan, and they had him sent out of the capital
Chang'an to serve as the sheriff of Henan County (), one of the two counties making up the eastern capital
Luoyang. Yuan subsequently left governmental service for some time while observing a mourning period after his mother's death. Once the mourning period was over, he was recalled to governmental service, to serve as
Jiancha Yushi (), a mid-level imperial censor. While stopping at the imperial messenger post at Fushui (敷水, in modern
Weinan,
Shaanxi), Yuan got into a dispute with an imperial eunuch messenger — variously reported as either Liu Shiyuan () (by the
Old Book of Tang) or
Qiu Shiliang (by the
New Book of Tang), in which the eunuch, as a result of the dispute, hit Yuan's face and injured him — Emperor Xianzong ruled that Yuan had overstepped his authorities as censor and demoted him to serve as the logistics officer at Jiangling Municipality (江陵, in modern
Jingzhou,
Hubei), despite defenses submitted on his behalf by
Li Jiang,
Cui Qun, and Bai. While at Jiangling, Yuan wrote many poems, and his style and Bai's were both popular and referred by the populace as
Yuanhe Style () —
Yuanhe being Emperor Xianzong's
era name. The eunuch monitor of Jingnan Circuit (荊南, headquartered at Jiangling), Cui Tanjun (), was impressed by Yuan's talents and did not treat him as a subordinate, but rather with great respect; he also often collected Yuan's poems and recited them. Meanwhile, sometime thereafter, Yuan was made the military advisor to the prefect of Tong Prefecture (通州, in modern
Nantong,
Jiangsu), while Bai was made the military governor of Jiang Prefecture (江州, in modern
Nanchang,
Jiangxi). Despite the distance between the two, they often wrote poems to each other, which often ran 30 to 50 lines, sometimes up to 100 lines. The people of the
Yangtze River region became impressed by their poems and often read and studied them. Many of Yuan's poems showed his sadness at being exiled from the capital. == During Emperor Muzong's and Emperor Jingzong's reigns ==