During the Tang dynasty's rule in China (618–907), a complex relationship between imperial China and the Tibetan Empire developed. During this period Chinese and Tibetan forces had many battles since both parties were military powers, but there were also years of peace and friendly relations.

The Old Book of Tang recorded the first ever embassy from Tibet arrived in China from the Tibetan emperor Songtsen Gampo in the 8th Zhenguan year or 634 CE.Lee 1981, pp. 6-7 Tang chronicles describe this as a tribute mission, but it brought an ultimatum demanding an alliance through marriage, not subservient rituals.Powers 2004, pg. 31 When Emperor Taizong of Tang refused a marriage alliance, Songtsen Gampo sent an army to attack the Chinese frontier city of Songzhou in 638, which was the first military conflict between the rising Tibetan Empire and the Chinese Tang dynasty. After a Tang army inflicted heavy casualties on the Tibetans in a night-time attack, Songtsen Gampo withdrew. He sent emissaries and tributes to Tang capital Chang'an to apologize, and to again request marriage. Taizong decided to give Songtsen Gampo a distant niece, Princess Wencheng, in marriage. The peace held for the remainder of the reigns of Taizong and Songtsen Gampo.

History Although some materials show that Tibet had long been established as a political entity, no concrete historical evidence was recorded before the end of the 6th century. In the late 6th century A.D, the leader of the Yarlung valley tribe in Shannan Prefecture of Tibet, Namri Songtsen, started a unification war and conquered a tribe named Sumpa. Thereafter Songtsen Gampo, the son of Namri Songtsen, established a capital in Luoxie after defeating the Yangtong, Bailan, Dangxiang and Fuguo successively, building a strong Tibet kingdom, which made him the first person to successfully unite Tibet.

The Tang dynasty at the time was in its prime. In 630 A.D., Li Shimin, the second Tang emperor, was respectfully called "Heavenly King" by leaders in western China. Tang and Tibet started an unavoidable relationship in economy, politics and other areas.

Envoys sent by Songtsen Gampo came to Tang China to pursue a friendly relationship with the Chinese in the eighth year of Zhenguan (the reign title of Li Shimin), i.e. 634 AD, and brought back Tang officials, who settled in Tibet. In 636 A.D, Songtsen Gampo invaded Tuyuhun, a vassal country of Tang, on the pretext of blaming the declined of political marriage proposal by Tang to Tuyuhun. Tang entitled Hou Junji, the minister of the official personnel affairs department, to the Chief Administrator of Dangmi Vennue; Zhi shi Si-li, the Leading General of the Right, to the Chief Administer of Bailan Vennue; Niu Jinda, the military defense general of left, to the Chief Administer of Kuoshui Venue; Liu Jian, the Leading General of the Left, the Chief of Taohe Vennue, to lead the army of Tang to defend Tuyuhan. Songtsen Gampo was frightened after being defeated by the spearhead of Tang led by Niu Jinda, and withdrew his army from Tuyuhun, Dang Xiang and Baiyuqiang before the arrival of the principal force led by Hou, and sent envoys to Tang to apologize for the attack.

First political marriage Songtsen Gampo then decided to change the marriage proposal into a peaceful one after seeing the prosperity of Tang, and it is recorded that Songtsen sent his chancellor, Gar Tongtsen Yulsung, to Tang with five thousand golds and hundreds of antique treasures to show his sincerity. Two years later, after receiving the third political marriage proposal by Songtsen Gampo, the emperor of Tang selected a daughter from royal nobility to be the wife of Songtsen Gampo and crowned her Princess Wencheng. What's more, the emperor of Tang appointed Li Daozong, the Minister of Rites and the Highness of Jiangxia, to convoy the Princess with a tally that symbolized the power of the Tang emperor to Tibet. Princess Wencheng entered Tibet in 641 A.D, and brought various production techniques of Tang China, including 60 books on manufacturing and construction techniques, over 100 remedies for up to 404 illnesses, 5 methods of medical diagnosis, 6 medical devices and 4 medical weighty tomes, along with a myriad of living items and crop seeds, to Tibet. According to the classic of The New Book of the Tang Dynasty, Songtsen Gampo welcomed his bride in Baihai and Princess Wencheng lived in Tibet for nearly 40 years until she died in 680 AD. This was the first formal contact established between Tang and Tibet.

Tang and Tibet maintained a peaceful and friendly relationship when Songtsen Gampo was alive and the diplomatic communication increased gradually every year, making Tibet a transportation hub between Tang and Sindhu (now India). In 645 A.D, the emperor Li Shi-min returned to Chang'an, the capital of Tang, after conquering Goguryeo, and Songtsen Gampo immediately sent an envoy, Gar Tongtsen Yulsung, to Chang-an to congratulate Li on his triumph with a gift of a seven-foot tall golden goose. Three years later, Wang Xuance, the Tang envoy who visited Sindhu, was looted, as Sindhu was in military disorder, and escaped to Tibet, where Songtsen Gampo dispatched armies and recruited soldiers from Nepal to assist Wang in suppressing the conflicts in Sindhu at the Battle of Chabuheluo, safely bringing back the whole diplomatic mission along with hundreds of prisoners of war to Chang'an. The stone tablet of the Tang envoy who visited Sindhu is still kept in the Gilong town of Tibet, recording Wang's revisit to Sindhu bypassing Tibet in the third year of Xianqing (658A.D), the reign title of Emperor Gaozong.

Emperor Li Shimin died in the year of 649 A.D and the throne was then acceded by his son, Li Zhi, namely Emperor Gaozong. Li Zhi sent an envoy to Tibet with the news of his father's death and offer an honorary title of Groom martial supervisor and Highness of Xihai to Songtsen Gampo while Gampo in return sent a special representative to Chang'an to attend the funeral of Li Shimin, with a tribute of 15 gold, silver and jewelry, as well as congratulations and expressions of his support for Li Zhi. Zhangsun Wuji, the civil and administrative official, also received a diplomatic statement from Gampo saying that Tibet would not hesitate to send armies to help if there were any unfaithful officials in Tang who dared to threaten the authority of the emperor. Thereafter Li Zhi progressed Songtsen Gampo's title to ‘the king of Cong’ and put a stone statue of Songtsen Gampo before Zhao mausoleum, the mausoleum of Li Shimin.

Mangsong Mangtsen, the grandson of Songtsen Gampo, took over his grandfather's crown in 650 A.D after Songtsen Gampo died. However, the actual executive power was in the hand of Gar Tongtsen Yulsung, who continued Songtsen Gampo's political policy of improving and revising the law, checking family registration and implementing tax policy to ensure the inner stability of Tibet. He also availed himself of the inner turmoil in Tuyuhun, attacking it several times even at the risk of conflict with Tang, who had long supported Tuyuhun. After the death of Gar, his son (or perhaps his grandson), Gar Trinring Tsendro, took control of Tibet. To support Tuyuhun, Tang convoyed the king of Tuyuhun, Murong nuohebo, back to his country in 670 A.D, with an army of over a hundred thousand soldiers, but encountered a Tibetan army of over 200 thousand soldiers deployed by Gar Trinring Tsendro, and was defeated in the battle of Dafeichuan. From then on, Tibet strengthened its control over the western region of Qinghai Lake but lost a war with Tang for the eastern region of Qinghai Lake and four towns in Anxi.

The posthumous son of Mangsong Mangtsen, Tridu Songtsen, became king of Tibet after his father's death in 676 A.D but the political power was still in the hand of Gar Trinring Tsendro. As Tridu Songtsen grew up, from 695 A.D to 698 A.D, Tsendro's family was denounced and crusaded against for threatening the power and authority of the king, as well as conflicting with other noble families. Gar Trinring Tsendro finally committed suicide in Zongke, Qinghai province after a rout in battle. Gar Tsenye Dompu, brother of Tsendro, and his son Gar Mangpoje, surrendered to Tang after their defeat and were respectively given the titles ‘Assisting general and Highness of GuiDe’ and ‘Marquis of Anguo’. Mangpoje progressed to Highness of Ba Chuan for outstanding contribution in war and his descendants all stayed in Tang to be Tang officials.

Second political marriage The kingship of the Tibetan kingdom, therefore, was strengthened. However, shortly after he eliminated the threat of the Gar family, Tridu Songtsen died in a war to vanquish a region called Nanzhao, and his one-year-old son, Me Agtsom, succeeded to the throne of Tibet under the help and supervision of his grandmother, Thrimalo. With hope for peace and friendship as both Tang and Tibet at that time suffered the painful results of years of war, Thrimalo sought a political marriage with Tang again for Me Agtsom as she had once done for her son. Emperor Zhongzong agreed to the marriage proposal and sent Princess Jincheng along with a special gift of part of the Yellow River region (the region above Gui-de whose name was Tangmu town). This region later was retaken by Wang Zhongsi and Geshu Han in a later war that defeated Tibet in 710 A.D. The emperor himself led a group of Tang officials and saw Princess Jincheng off with a solemn farewell ceremony in Shiping town.

In 731 A.D, Me Agtsom and Princess Jincheng dispatched an envoy to Tang to ask for ancient Chinese classics of Mao's Explanation on the Book of Songs, Books of Rites, and Spring and Autumn Annals, as well as seeking an open market and boundary division, with a statement from Me Agtsom saying that Tang and Tibet were of the same family, as he was the distant nephew of the former emperor and was now the husband of Princess Jincheng, and therefore the people of both countries should enjoy a peaceful and joyful life. Tang and Tibet then established a monument in Chiling (now ‘sun and moon mountain’ in Qinghai province) as the boundary between the two countries. Frontier generals and officials from both countries attended the open market in Chiling and Gan Song-ling made an official announcement that prohibited robbery and attack, and to maintain a friendly relationship.

However, wars still broke out shortly after as both Tang and Tibet wanted to expand their territory and power, and frontier generals wanted to seize more fame and military exploits. Military officers such as Li Wei, Zhang Shougui, Wang Zhongsi, Ge Shuhan defeated Tibet in the regions from east to west successively, making Tibet sue for peace for several times. In 754 A.D, two ministers of Tibet, Bel Dongtsab and Lang Nyesig, rebelled and killed king Me Agtsom. In 755 A.D, a 13-year-old new king, Trisong Detsen, took power. The same year, the cataclysmic An-Shi Rebellion broke out in Tang. Emperor Xuanzong fled from Chang'an to Sichuan and the deployment of Tang's army to suppress the rebellion gave Tibet the opportunity to occupy the Tang territories of Longyou, Hexi and four towns in Anxi.

In October of 763 A.D, they availed themselves of the opportunity created by discord between the emperor and Tang officials, and in addition the Shuofang army turned a blind eye on their aggression in the east, so Tibet occupied Chang'an with an army of 200 thousand soldiers, forcing Emperor Daizong to escape to Shanzhou, and selected Li Chenghong, brother of Princess Jincheng, as the new emperor. The Tibetan army withdrew after occupying Chang'an for 15 days on hearing that Tang's loyal army was marching toward the city.