In 1279, the Yuan dynasty decisively defeated the Song dynasty in the Battle of Yamen, which marked the end of the Song dynasty and began the total control of Kublai Khan over China. As a result, Kublai Khan began to expose his attempt to take over the southern countries like Đại Việt or Champa. Aware of the situation, Thánh Tông and Nhân Tông began to prepare the military for the obvious and inevitable war while trying to maintain a flexible policy towards the Yuan dynasty. Prince Chiêu Văn Trần Nhật Duật was appointed with the task of pacifying the revolt led by Trịnh Giác Mật in Đà Giang by diplomatic means to keep the country stable before the war. With his knowledge of the minority people's language and culture, Trần Nhật Duật successfully accomplished his task in 1278; the Trần dynasty was hence free to deal with the threat from the north. In October 1282, Retired Emperor Trần Thánh Tông and Emperor Trần Nhân Tông gathered all members of the royal family, the Trần clan, and officials at the royal court in Bình Than to discuss the unavoidable war. Two prominent generals of the Đại Việt army who were noticed on this occasion were Trần Khánh Dư, the former commander of the army but who was deprived of all titles after his guilt, and Trần Quốc Toản, a marquis who was only sixteen years old. In 1283, Prince Hưng Đạo Trần Quốc Tuấn was appointed the commander-in-chief () of the Đại Việt army, and the Retired Emperor and the Emperor began to hold military exercises with their generals and troops.