Li Shangyin's career was rough, and he never obtained a high position, either because of factional disputes, or because of his association with Liu Fen (劉蕡), a prominent opponent of the eunuchs.
Li Shangyin lived at a time when the Tang Dynasty, after some two hundred years of glorious reign, was fast declining. Culturally, politically and economically the Tang was one of the great periods of Chinese history. The cosmopolitan capital of Chang'an was filled with traders from the Middle East and other parts of Asia where many Asian vassal states sent envoys to pay tribute. The empire covered a vast territory, the largest yet in the history of China. The nation, under the reign of Emperor Gaozuyi] through Taizong, Empress Wu to the time of Xuanzong, steadily grew to the height of its prosperity. After the An Lushan Rebellion, however, the political and economic structure of the country began to disintegrate and the Dynasty went rapidly into decline. The rebel generals fighting against the Tang court during and after the An Lushan Rebellion were allowed to surrender and given military governor posts even after the leaders of the rebellion were vanquished. Peace and stability over the entire area of Hebei was heavily bought by a compromise settlement. These provincial governors paid only lip service to the central government. The court, now weak and impotent, tolerated their growing independence, wary also of the aggression of the Tibetans to the north-west who posed a constant threat to the capital. During the subsequent years, military governors repeatedly challenged imperial authority with attempts to claim hereditary succession, resulting in revolts and bloodshed. Apart from this loss of control over the provincial military leaders and other problems at the frontiers, the Tang court was internally plagued by the increasingly powerful eunuchs and the fierce Niu-Li factional strife. The eunuchs first gained political influence as a group when Gao Lishi helped Emperor Xuanzong in his rise in power.3 Later, Li Fuguo also helped to put Su-zong on his throne. By gaining royal patronage eunuchs gradually controlled personal access to the emperors and participated in the business of the central government. They also involved themselves with provincial appointments, at times, even intervening with armed forces in disputes over imperial successions. By the time of Li Shangyin, the emperors had allowed the eunuchs to become fully entrenched both militarily and politically. After Xianzong, all Tang emperors (except Jingzong were put on the throne by the eunuchs. In 835, the infamous "Sweet Dew Incident" occurred during the reign of Emperor Wenzong. A palace coup designed by Li Xun (the prime-minister) and Zheng Zhu (the military governor of Feng Xiang) support of Wenzong's effort to overthrow the eunuchs failed. eunuchs, led by Qiu Shiliang slaughtered the clans of many high officials and chief ministers. A great many other innocent people were killed in connection with this event. The eunuchs whose power had been growing out of control now completely dominated the Emperor and the affairs of state. Apart from the eunuchs, the Niu-Li factional strife was another destructive internal force haunting the Tang court. The Niu and Li factions were not organized political parties, but two groups of rival politicians, hostile toward each other as a result of some personal animosity. The head of the Niu faction was represented by Niu Sengru and Li Zongmin and the Li faction by Li Deyu. In the 830s, the two contending factions created much turmoil in court through the reigns of Muzong, Jingzong, Wenzong, Wuzong and Xuanzong, a period coinciding almost exactly with Li Shangyin's life. According to Chen Yinke, the struggle was also due to a difference in social background between the two groups, one representing the traditional ruling class of North China, and the other, the newly risen class of scholar-officials who reached their positions through the civil service examinations. In any case, many intellectuals and high officials were involved in this struggle. Whenever members of one faction were in power, people associated with the other faction would be demoted, or out of favor. The factional strife kept court officials from uniting against the increasing power of the eunuchs. The emperors, rendered completely helpless, tried to play one force against another. It was some fifty years after Li Shangyin's death that the eunuchs were finally eradicated with the help of the military governors, precipitating the downfall of Tang. The forty-five years of Li-Shangyin's life covered the reign of six emperors. Among them, Xianzong and Jingzong were murdered by the eunuchs. Muzong, Wuzong and Xuanzong indulged in escapist practices, dying, in the case of Wuzong, of an overdose of elixir drugs.
Li was a typical Late Tang poet: his works are sensuous, dense and allusive. The latter quality makes adequate translation extremely difficult. The political, biographical or philosophical implications supposed to be contained in some of his poems have been a subject of debate for many centuries in China.
His most famous and cryptic poem is called "Jin Se" (錦瑟) (the title is only taken from the first two characters of the poem, since the poem is one of Li's "no title" poems), which consists of 56 characters and a string of images. His "no title" poems are regarded as "pure poetry" by some modern critics.
Although more famous for his sensuous poems, Li indeed wrote in many styles, sometimes be satirical, humorous or sentimental. Moreover, some ancient critics hold that he is the only poet who, in some of his poems, succeeds in imitating the masculine quality of Du Fu's works.
In 1968, Roger Waters of the rock band Pink Floyd borrowed lines from his poetry to create the lyrics for the song "Set the Controls for the Heart of the Sun" from the band's second album A Saucerful of Secrets.
Part of a poem by Li Shangyin is recited by a minor character in the Mortuary in the role-playing video game Planescape: Torment.
More recently, Li Shangyin's poem, "When Will I Be Home?" is alluded to and quoted from by Hig, the protagonist of Peter Heller's 2012 novel, The Dog Stars. The novel ends with a reprinting of the poem in full.
His name is mentioned and his poem is quoted in the Korean TV Series Gu-am Heo Jun, Episode 119.