Emperor Hsuan Tsung, who ruled from 713-756, became infatuated with Yang Kwei-fei, and the infatuation ended up destroying his reign and eventually the entire empire, marking the end of the Tang dynasty. In the end, the emperor was forced to have Yang Kwei-fei killed.
Yang Kwei-fei (Yokichi in Japanese), a commoner, was originally married to the emperor’s son, whom she leaves to enter a convent. The emperor, finding her in the convent, plucks her out and makes her his “despot of the night.”
An Lu-shan is a general of Turkish decent. He too has relations with Yang Kwei-fei, and leads a rebellion against the emperor in 755.
A Taoist priest goes to retrieve Yang Kwei-fei from the afterlife (some magic island in the Eastern seas), and, upon finding her, receives a message from the emperor reminding him of their vow to meet on the seventh day of the seventh months (the day of the "Tanabata festival" in Japan).
[An English translation of the poem is availabe by Witter Bynner]