Following independence from Chinese rule in 939 CE, Vietnam faced a turbulent period marked by internal conflicts. When Ngo Quyen, who had liberated the region, passed away after a brief five-year reign, Nam Viet fell into disorder as twelve warlords contested for control. In 968 CE, Dinh Bo Linh emerged as the unifying force, consolidating the country and ensuring stability by establishing a tributary relationship with the Chinese emperor—a practice that would continue until the 19th century. Dinh Bo Linh further strengthened security by relocating the capital to the defensible valley of Hoa Lu, which served as the seat of power during the brief Dinh and Early Le dynasties.

These early rulers set the foundation for a centralized state, implementing significant reforms in administration and military organization and initiating an ambitious road-building program. However, it was under the Ly dynasty, founded by Ly Thai To in 1009 CE, that Vietnam, then known as Dai Viet, secured its independence and enjoyed enduring stability for the next 400 years. One of Ly Thai To’s first actions was to relocate the capital back to the fertile Red River Delta, where he established Thang Long, the ancient precursor to modern Hanoi.

Ly Thai To’s successor, Ly Thai Tong (1028–1054), further strengthened Dai Viet by transforming the army into a formidable professional force, capable of defending the northern borders and expanding southward. This newly empowered military, led by the esteemed General Ly Thuong Kiet, launched a pre-emptive strike against the Song Chinese in 1076, successfully repelling the subsequent counterattack and showcasing Dai Viet’s growing influence and military prowess.