Nanam Shang Gyaltsen Lhanang, also known as Shang Gyaltsen, was a famous general of the Tibetan Empire. In Chinese records, his name was given as Shàng Jiézàn. Shang Gyaltsen was born and raised in Nanam clan. The famous Dharma king, Trisong Detsen, was his nephew. After a long-term conflict against the Tang China, Trisong Detsen tended to sign a peace treaty with Chinese. But two high generals, Chimshang Gyalsig Shuteng and Nganlam Takdra Lukhong, strongly opposed to the proposal. Only Shang Gyaltsen supported the king. The king dismissed two generals from their posts, and appointed Shang Gyaltsen as Lönchen. Shang Gyaltsen went to Tang China in 783, to meet with Chinese general Zhang Yi, and swore an oath of friendship between the two states. China fell into civil war in the next year. The Chinese capital Chang'an was occupied by Zhu Ci, one of a Chinese rebellion army leaders. Shang Gyaltsen sent a mission to China, suggested that China could request Tibetan reinforcements for help. The Chinese emperorDezong had to take his suggestion, and promised to cede Beiting and Anxiin return. Shang Gyaltsen sent 20 thousand men to help Tang China, but before they reached Chang'an, Zhu Ci was killed by his general and the rebellion was quickly put down. Then Shang Gyaltsen sent another mission to China, asked Dezong to fulfill the promise, but was refused because the two places were both strategic strongholds and the Tibetan troops had never actually helped them. Shang Gyaltsen was infuriated. He sent troops to invade China, sack Yanzhou, Xiazhou, Yinzhou and Linzhou, threatened to Chang'an. He sent an envoy to Chinese, said that he wanted return the occupied lands, and reiterated his territorial claim before. He requested Chinese emperor sent three representatives to negotiate a peace treaty, and the three representatives should be Hun Jian, Ma Sui and Li Sheng, all of them were Chinese famous generals. His request was accepted; by summer 787, Ma Sui and Hun Jian, as Emperor Dezong's emissary, was set to meet with Shang at Pingliang River. Shang Gyaltsen laid a trap for Hun and launched a sudden attack, killing and capturing many of Hun's attendants, but Hun escaped. In order to further aggravate Emperor Dezong's attitude toward Ma, he intentionally released Ma's nephew Ma Yan, along with the imperial eunuch messenger Ju Wenzhen. Dezong was taken in; from then on, the three generals were not trusted. Shang Gyaltsen came into conflict with the queen, Tsepangsa Magyal Dongkar, and her clan. Tsepangsa was the most important supporter of Bön, so, the king drifted apart the queen's clan, prohibited them to take part in political affairs, and sent dbu ring, whom was Shang Gyaltsen's son, to guard the palace gate. Prince Murug, who was the queen's own son, killed dbu ring, broke into the palace. Trisong Detsen was angered, exiled Murug to Changtang. Shang Gyaltsen died in 796.