Zhang Xuanjing was born in 350, during the reign of his father
Zhang Chonghua (Duke Jinglie). His mother was likely Zhang Chonghua's
concubine Lady Guo (as he honored her as princess dowager in 363, which he would have had little reason to do if she were not his mother). He had an older brother,
Zhang Yaoling, who was his father's
heir apparent. In 353, Zhang Chonghua died, and Zhang Yaoling became the ruler (as Duke Ai), but actual power was in the hands of Zhang Chonghua's older brother
Zhang Zuo, who was having an affair with Zhang Chonghua's mother
Princess Dowager Ma and received her support in early 354 to depose Zhang Yaoling and claim the throne himself. Later that year, when he declared independence from
Jin Dynasty (266–420), which Former Liang had been a titular vassal of, he created Zhang Xuanjing the Marquess of Liangwu. In 356, the violent and capricious Zhang Zuo was overthrown and killed by the generals
Zhang Guan and
Song Hun. Initially, Song had Zhang Xuanjing claim the Jin-created title of Duke of Xiping, a title that his ancestors had carried for generations, but Zhang Guan overruled Song and had the young ruler claim the title Prince of Liang, a title that Jin had declined to grant previously. Zhang Guan served as regent. == Under the regency of Zhang Guan ==