Li Sisheng was born in 711, during the second reign of his grandfather Emperor Ruizong, as the third son of his father, then the Crown Prince, Li Longji, who would later become Emperor Xuanzong. His mother Consort Yang Guipin (posthumously Empress Yuanxian) was from the imperial clan of the preceding Sui dynasty. Her great-grandfather Yang Shida () was a high -level official during Sui and had been given the title Prince of Zheng (). Her father Yang Zhiqing () was a general of the imperial guards during Tang. At the time that Consort Yang Guipin was pregnant with Li Sisheng, Li Longji was locked in a power struggle with his aunt, Emperor Ruizong's sister Princess Taiping, and it was said that Princess Taiping had placed many associates in the crown prince's palace to spy on Li Longji and that she did not want him to have many sons. (He already had two by that point—Li Sisheng's older brothers Li Sizhi, later named Li Cong (by Consort Liu) and Li Siqian, later named Li Ying (by Consort Zhao).) Li Longji was worried that, if Princess Taiping found out that Yang Guipin was pregnant, Princess Taiping's associates might harm him, and he spoke to a close associate, Zhang Shuo, stating: "A powerful individual did not want me to have many sons. I am afraid that this woman would become a target. What do you think?" Li Longji began to prepare an herbal stew that, in traditional Chinese medicine, was believed to be able to induce an abortion, but as he did so, fell asleep and had a dream that a god descended and overturned the "ding" holding the stew. When he told Zhang this as well, Zhang responded, "This is heaven's will. You should not worry." (As a result, later on in life, Li Sisheng would feel personally indebted to Zhang Shuo.)