structural:expansion
Mongol invasions

In 1257, the first Mongol invasion of Đại Việt was launched with the purpose of opening a southern front against the Song dynasty, whom they were fighting for more than two decades. The Mongols had already conquered parts of modern-day Sichuan and the Dali kingdom in modern-day Yunnan in order to besiege the Southern Song from the west. Trần Thái Tông opposed the encroachment of a foreign army across his territory and so dispatched soldiers on elephants to deter the Mongol troops. The elephant-mounted troops were routed by sharpshooters targeting the elephants. In comparison with the previous Ly dynasty, the Tran had strengthened their armed forces and were able to deter the Mongol attacks.

At the beginning of the war, the Đại Việt army suffered several defeats at the hands of an overwhelming force that had already conquered a vast area in Asia. Several high-ranking officials of the Trần dynasty were so fearful that Prince Trần Nhật Hiệu, the younger brother of Thái Tông, even suggested to the Emperor that they might escape from Đại Việt to the Song dynasty.

Trần Thái Tông submitted to the Mongols after the loss of a prince and the capital. In 1258, the Trần commenced regular diplomatic relations and a tributary relationship with the Mongol court, treating them as equals to the embattled Southern Song dynasty without renouncing their ties to the Song.

Kublai Khan was dissatisfied with the arrangement at the end of the first invasion and requested greater tributary payments, including taxes to the Mongols in both money and labor, "incense, gold, silver, cinnabar, agarwood, sandalwood, ivory, tortoiseshell, pearls, rhinoceros horn, silk floss, and porcelain cups", and direct oversight from a Mongol-appointed darughachi. In 1283, Khubilai Khan sent word to the Trần that he intended to send Yuan armies through Trần territory to attack the kingdom of Champa, with demands for provisions and other support to the Yuan army.

In the twelfth lunar month of 1284, the second Yuan invasion of Đại Việt was launched under the command of Kublai Khan's prince Toghon. Đại Việt was attacked from two directions, with Toghan himself conducting an infantry invasion from the northern border while the Yuan navy under general Sogetu advanced from the southern border through the territory of Champa.

Initially, Trần Thánh Tông and Trần Nhân Tông had to order the army to retreat to avoid the pressure from the Yuan force when Prince Chiêu Minh Trần Quang Khải commanded his troops to stop Sogetu's fleet in the province of Nghệ An. Meanwhile, several high-ranking officials and members of the imperial family of the Trần dynasty defected to the Yuan side, including Thánh Tông's own brother, Prince Chiêu Quốc (Trần Ích Tắc), and Trần Kiện, who was the son of Prince Tĩnh Quốc (Trần Quốc Khang). To ensure the safety of Thánh Tông and Nhân Tông during their retreat, Princess An Tư was offered as a present and diversion for Prince Toghan, while Marquis Bảo Nghĩa (Trần Bình Trọng) was captured and later killed in the Battle of Đà Mạc defending the two emperors. The mass defections were the result of the significant effect that recent Mongol conquest of the Southern Song had on contemporary observers, with a Mongol conquest of Vietnam appearing inevitable to many.

At the southern border, Trần Quang Khải also had to retreat under the pressure of Sogetu's navy and the defection of the governor of Nghe An. This critical situation for the Trần dynasty began to change after the Toghan made the decision to retreat with the forward troops their victory in the fourth lunar month of 1285 at the Battle of Hàm Tử, where the troops commanded by Trần Nhật Duật, Prince Chiêu Thành, Trần Quốc Toản, and Nguyễn Khoái were finally able to defeat the fleet of general Sogetu. On the tenth day of the fifth lunar month of 1285, Trần Quang Khải fought the decisive battle in the Chương Dương, where the Yuan navy was almost destroyed and the balance in the battlefield tilted definitively in favor of the Trần dynasty. Ten days later Sogetu was killed and the Trần Emperor Nhân Tông and Emperor Emeritus Thánh Tông returned to the capital, Thăng Long, on the sixth day of the sixth lunar month, 1285.

In the third lunar month of 1287, the Yuan dynasty launched their third invasion of Đại Việt. This time, unlike the second invasion, commander-in-chief Prince Hưng Đạo (Trần Quốc Tuấn) assured the Emperor that Đại Việt's army could easily break the Yuan military campaign. After occupying and looting the capital, Toghan decided to retreat with the forward troops. This invasion was indeed ended one year later by a disastrous defeat of the Yuan navy at the Battle of Bạch Đằng on the eighth day of the third lunar month, 1288. Besides Trần Quốc Tuấn, other notable generals of the Trần dynasty during this time were Prince Nhân Huệ Trần Khánh Dư, who destroyed the logistics convoy of the Yuan navy at the Battle of Vân Đồn, and general Phạm Ngũ Lão, who took charge of ambushing prince Toghan's retreating troops. After the destruction of the Mongol navy, both the Đại Việt and Champa decided to accept the nominal supremacy of the Yuan dynasty and serve as tributary states in order to avoid further conflicts.

Professor Liam Kelley noted that people from Song dynasty China, such as Zhao Zhong and Xu Zongdao, fled to the Tran dynasty after the Mongol invasion of the Song and helped the Tran fight against the Mongol invasion. Like the Tran dynasty, the Daoist cleric Xu Zongdao originated from Fujian. He recorded the Mongol invasion and referred to the Mongols as "Northern bandits".

Nguyễn Trung Ngạn, head of an envoy mission to the Yuan court in 1314, referred to the Yuan dynasty as Hồ (胡), meaning barbarians, in his poem Bắc sứ túc Khâu Ôn dịch (北使宿丘溫驛):

江山有限分南北， The land is divided into North and South 胡越同風各弟兄。 "Hồ" and Viet are brothers with same customs

Later on, Wu Bozong 吳伯宗 (b. 1334-d. 1384) was sent as Ming ambassador to Vietnam. Wu wrote in the Rongjinji (榮進集) that when he asked the Tran monarch about Annam's affairs, the Tran ruler said that the kingdom still adhered to Tang dynasty and Han dynasty customs.

欲問安南事， Asking about Annam situation? 安南風俗淳。 Annam customs are traditional 衣冠唐制度， Clothing are Tang's standard 禮樂漢君臣 Music and Rites are similar to Han's court