During the An Lushan Rebellion, as Emperor Xuanzong and his cortege were fleeing from the capital Chang'an to Chengdu, the emperor's guards demanded that he put Yang to death because they blamed the rebellion on her cousin Yang Guozhong and the rest of her family. The emperor capitulated and reluctantly ordered his attendant Gao Lishi to strangle Yang to death.

Yang was born in 719 during the Tang Dynasty, early in the reign of Emperor Xuanzong. Her great-great-grandfather Yang Wang (楊汪) was a key official during the reign of Emperor Yang of Sui, and, after the fall of the Sui Dynasty, served one of the contenders to succeed Sui, Wang Shichong; Yang Wang was then killed when Wang Shichong was defeated by Tang forces in 621.[3] Yang Wang was from Huayin (華陰; in modern Weinan, Shaanxi), but his clan subsequently relocated to Yongle (永樂; in modern Yuncheng, Shanxi).

Yang's father Yang Xuanyan (楊玄琰) served as a census official at Shu Prefecture (蜀州; in modern Chengdu, Sichuan), and his family went there with him. He appeared to have had no sons, but had four daughters who were known to history — Yang Yuhuan and three older sisters.[4] Yang Xuanyan died when Yang Yuhuan was still young, so the latter was raised by her uncle Yang Xuanjiao (楊玄璬), who was a low-ranking official at Henan Municipality (河南府; modern Luoyang).

In 733, fourteen-year-old Yang Yuhuan married Li Mao, the Prince of Shou and the son of Emperor Xuanzong and Consort Wu. She thus carried the title of Princess of Shou. After Consort Wu died in 737, Emperor Xuanzong was greatly saddened by the death of his then-favorite concubine. Some time after that, however, Princess Yang somehow came into Xuanzong's favor and the Emperor decided to take her as his consort. However, since Princess Yang was already the wife of his son, Emperor Xuanzong stealthily arranged her to become a Taoist nun, with the tonsured name Taizhen, in order to prevent criticism that would affect his plan of making her his concubine. Yang then stayed, for a brief moment, as a Taoist nun in the palace itself, before Emperor Xuanzong made her an imperial consort after bestowing a new wife on his son Li Mao. Yang became the favorite consort of the Emperor.

In 745, after Emperor Xuanzong gave the daughter of the general Wei Zhaoxun (韋昭訓) to Li Mao as his new wife and princess, he officially made Taizhen an imperial consort — with the newly created rank of Guifei, which was even greater than the previously highest rank of Huifei, carried by Consort Wu. He bestowed posthumous honors on her father Yang Xuanyan and granted her mother the title of Lady of Liang. He also gave high offices to her uncle Yang Xuangui (楊玄珪) and cousins Yang Xian (楊銛) and Yang Qi (楊錡). Her three older sisters were conferred the ranks of Ladies of Han, Guo, and Qin, and it was said that whenever the noble women were summoned to imperial gatherings, even Emperor Xuanzong's highly honored sister Li Chiying (李持盈), the Princess Yuzhen, did not dare to take a seat more honorable than theirs. Emperor Xuanzong also gave his favorite daughter Princess Taihua (born of Consort Wu) to Yang Qi in marriage. The five Yang households — those of Yang Xian, Yang Qi, and the Ladies of Han, Guo, and Qin — were said to be exceedingly honored and rich, and all of the officials fought to flatter them. Also around the same time, her second cousin Yang Zhao (whose name was later changed to Yang Guozhong) was also introduced to Emperor Xuanzong by Consort Yang, and Yang Zhao began to be promoted due to his flattery of the emperor.

Consort Yang became so favored that whenever she rode a horse, the eunuch Gao Lishi would attend her. 700 laborers were conscripted to sew fabrics for her. Officials and generals flattered her by offering her exquisite tributes. In 746, she angered Emperor Xuanzong by being jealous and rude to him, and he had her sent to her cousin Yang Xian's mansion. Later that day, however, his mood was such that he could not eat, and he battered his servants for minor offenses. Gao knew that he missed Consort Yang, and requested that the treasures in Consort Yang's palace be sent to her. Emperor Xuanzong agreed, and sent imperial meals to her as well. That night, Gao requested that Emperor Xuanzong welcome Consort Yang back to the palace, a request that Emperor Xuanzong easily agreed to. Thereafter, she was even more favored, and no other imperial consort drew his favor.

In 747, when the military governor (jiedushi) An Lushan arrived at the capital Chang'an to meet Emperor Xuanzong, Emperor Xuanzong showed him much favor and allowed him into the palace. He had An honor Consort Yang as mother and Consort Yang's cousins and sisters as his brothers and sisters.

In 750, Consort Yang again offended Emperor Xuanzong with her words, and he sent her back to her clan. The official Ji Wen (吉溫) told Emperor Xuanzong that he had overreacted, and Emperor Xuanzong regretted his actions. He again sent imperial meals to her, and she wept to the eunuchs delivering the meal, stating:

My offense deserves death, and it is fortunate that His Imperial Majesty did not kill me, but instead returned me to my household. I will forever leave the palace. My gold, jade, and treasures were all given me by His Imperial Majesty, and it would be inappropriate for me to offer them back to him. Only what my parents gave me I would dare to offer.

She cut off some of her hair and had the hair taken back to Emperor Xuanzong. Emperor Xuanzong had Gao escort her back to the palace, and thereafter loved her even greater.

In 751, An again visited Chang'an. On An's birthday on 20 February, 751,[5] Emperor Xuanzong and Consort Yang rewarded him with clothing, treasures, and food. On 23 February, when An was summoned to the palace, Consort Yang, in order to please Emperor Xuanzong, had an extra-large infant wrapping made, and wrapped the obese An in it, causing much laughter among the ladies in waiting and eunuchs. When Emperor Xuanzong asked what was going on, Consort Yang's attendants joked that Consort Yang gave birth three days before and was washing her baby Lushan. Emperor Xuanzong was amused by the comic situation and rewarded both Consort Yang and An greatly. Thereafter, whenever An visited the capital, he was allowed free admittance to the palace, and there were rumors that he and Consort Yang had an affair, but Emperor Xuanzong discounted the rumors.

In 752, when the chancellorLi Linfu, in light of Nanzhao incursions against Jiannan Circuit (劍南道; headquartered in modern Chengdu, Sichuan), of which Yang Guozhen served as commander remotely, wanted to send Yang Guozhong to Jiannan to defend against the Nanzhao attacks, Consort Yang interceded on Yang Guozhong's behalf, and Yang Guozhong did not actually report to Jiannan. Li Linfu soon died, and Yang Guozhong became chancellor.

Yang Guozhong and An Lushan soon were in conflict, and Yang Guozhong repeatedly acted provocatively, such as arresting and executing staff members from An's mansion in Chang'an. In 755, An finally rebelled and marched his troops toward the capital. In order to try to placate the populace, which believed that Yang Guozhong had provoked the rebellion, Emperor Xuanzong considered passing the throne to his crown prince, Li Heng. Yang Guozhong, who was not on good terms with the prince, feared this development, and persuaded Consort Yang and her sisters, the Ladies of Han, Guo, and Qin, to speak against it. Emperor Xuanzong, for the time being, did not abdicate the throne.

In 756, General Geshu Han was forced by Yang Guozhong to engage An out of fear that the general himself might usurp the throne; Geshu Han was defeated and Tong Pass, the last major defense, fell to An's forces. Yang Guozhong then suggested fleeing to Chengdu, the capital of Jiannan Circuit. On 14 July,[6] Emperor Xuanzong, keeping the news secret from the people of Chang'an, used the imperial guards to escort him, Consort Yang, her family, and his immediate clan members, and left Chang'an, heading toward Chengdu. Attending him were Yang Guozhong, his fellow chancellor Wei Jiansu, the official Wei Fangjin (魏方進), the general Chen Xuanli, and some eunuchs and ladies in waiting close to him.

On 15 July,[1] Emperor Xuanzong's cortege reached Mawei Courier Station (simplified Chinese: 马嵬驿; traditional Chinese: 馬嵬驛; pinyin: MǎwéiYì, in modern Xianyang, Shaanxi). The imperial guards were not fed and became angry at Yang Guozhong. Chen also believed that Yang Guozhong had provoked this disaster and planned to accuse him; he reported his plans to Li Heng through Li Heng's eunuch Li Fuguo, but Li Heng was hesitant and gave no approval. Meanwhile, Tibetan emissaries, who had followed Emperor Xuanzong south, were meeting with Yang Guozhong and complaining that they also had not been fed.

The soldiers of the imperial guard took this opportunity to proclaim that Yang Guozhong was planning treason along with the Tibetan emissaries, and they killed him, along with his son Yang Xuan (楊暄), the Ladies of Han and Qin, and Wei Fangjin. Wei Jiansu was severely injured and nearly killed, but was spared at the last moment. The soldiers then surrounded Emperor Xuanzong's pavilion and refused to leave, even after Emperor Xuanzong came out to comfort them and order them to disperse. Chen publicly urged him to put Consort Yang to death — which he initially declined. After Wei Jiansu's son Wei E (韋諤) and Gao Lishi spoke further, Emperor Xuanzong finally agreed. He had Gao take Consort Yang to a Buddhist shrine and strangle her. After he showed the body to Chen and the other imperial guard generals, the soldiers finally dispersed and prepared for further travel. Meanwhile, Yang Guozhong's wife Pei Rou (裴柔), son Yang Xi (楊晞), the Lady of Guo, and the Lady of Guo's son Pei Hui (裴徽) tried to flee, but were killed. Consort Yang was buried at Mawei, without a coffin, but with masses of fragrance wrapped in purple blankets.

In 757, Prince Li Heng, who had taken the throne as Emperor Suzong, recaptured Chang'an and welcomed ex-Emperor Xuanzong, then Taishang Huang (retired emperor) back to the capital. Emperor Xuanzong went through Mawei on his way back to Chang'an. He wanted to locate Consort Yang's body and rebury her with honor. The official Li Kui spoke against it, pointing out that the imperial guard might again mutiny if he did so. However, Emperor Xuanzong secretly sent eunuchs to rebury her with a coffin. When they found the body, it had decomposed, but the fragrance bag buried with her was still fresh. The eunuchs returned with the fragrance bag, and upon its presentation to Emperor Xuanzong, he wept bitterly. When he returned to Chang'an, he had a painter create a picture of Consort Yang in a secondary palace, and often went there to view the portrait.

Yang was known for having a full and fleshy figure, which was a much sought-after quality at the time. She was often compared and contrasted with Empress Zhao Feiyan, the wife of Emperor Cheng of Han, because Yang was known for her full build while Empress Zhao was slender. This led to the Four-character idiomyanshou-huanfei (simplified Chinese: 燕瘦环肥; traditional Chinese: 燕瘦環肥; pinyin: yànshòu-huánféi, literally "slender Yan, plump Huan"), describing the physical range of the types of beauties. Lychee was a favorite fruit for Yang, and the emperor had the fruit, which was only grown in southern China, delivered by the imperial courier's fast horses, whose riders would take shifts day and night in a Pony Express-like manner, to the capital. (Most historians believe the fruits were delivered from modern Guangdong, but some believe they came from modern Sichuan.) A copy of the outline of her right hand still exists, having been carved on a large stone at the site of the Xi'an Palace.[7] Yang was also granted use of the Huaqing Pool which had been the exclusive private pool of previous Tang emperors.

She is sometimes credited with the invention of the dudou, the traditional Chinese bodice or undershirt.

Yang's story has been often retold. While some literature describes her as the author of much misfortune, other writings sympathize with her as a scapegoat. In the following generation, a long poem, "Chang hen ge" ("Song of Everlasting Sorrow"), was written by the poet Bai Juyi describing Emperor Xuanzong's love for her and perpetual grief at her loss.[8] It became an instant classic, known to and memorized by Chinese schoolchildren far into posterity.

The story of Yang and the poem also became highly popular in Japan and served as sources of inspiration for the classical novel The Tale of Genji which begins with the doomed love between an emperor and a consort, Kiritsubo, who is likened to Yang. Noh plays have been staged based on her story. A Japanese rumour states that Yang had been rescued, escaped to Japan and lived her remaining life there. In Japanese, she is known as Yōkihi.

^Yang Yuhuan's three older sisters were described as having had birth ranks first, third, and eighth, implying that Yang Xuanyan might have had nine or more daughters, but it was also possible that their ranks were combined with their female cousins.