The future Empress Zhang's family was originally from Deng Prefecture (鄧州, roughly modern Nanyang, Henan).
Consort Dou was put to death by Emperor Ruizong's mother Wu Zetian in 693, while Li Longji was just eight.
During Emperor Xuanzong's Tianbao era (742-756), the future Empress Zhang was selected to be a concubine for Emperor Xuanzong's son and crown prince Li Heng, and she carried the title of Liangdi, the highest rank for the Crown Prince's concubines.
On the way to Jiannan Circuit (劍南, roughly modern Sichuan and Chongqing), however, Li Heng left Emperor Xuanzong's train and instead, following the suggestion of his son Li Tan the Prince of Jianning, decided to head for important border military outpost Lingwu to gather troops there to prepare for counterattack.
When Li Heng told her, "It is not a woman's responsibility to fight the bandits," she responded, "I am afraid that sudden disaster would occur.
Soon after Li Heng arrived in Lingwu, the officials and generals there urged him to take the throne, and he did (as Emperor Suzong).
Li Mi opined that in the difficult times, it would be inappropriate for her to use such a luxurious item, and therefore suggested instead that the jewels be removed and rewarded to those soldiers with accomplishments.
Meanwhile, she entered into an alliance with Emperor Suzong's trusted eunuch Li Fuguo, and together the two became powerful inside the palace, purportedly carrying out much misdeeds.
However, as of spring 762, when both Emperors Xuanzong and Suzong were seriously ill, Empress Zhang and Li Fuguo had begun to be rivals.
(During Emperor Suzong's illness, at one point, to display her love for him, she used her blood to write Buddhist sutras in order to seek blessing for him.