Following the death of Dinh Bo Linh in 979, the Song rulers attempted to reassert Chinese control over Vietnam. Le Hoan, the commander in chief of Dinh Bo Linh’s army, seized the throne and successfully repulsed the Chinese army in 981. Ly Cong Uan, a former temple orphan who had risen to commander of the palace guard, succeeded Le Hoan in 1009, thereby founding the great Ly dynasty that lasted until 1225. Taking the reign name Ly Thai To, he moved his capital to Dai La (modern Hanoi). The early Ly kings established a prosperous state with a stable monarchy at the head of a centralized administration. The name of the country was changed to Dai Viet by Emperor Ly Thanh Tong in 1054.
The first century of Ly rule was marked by warfare with China and the two Indianized kingdoms to the south, Cambodia and Champa. After these threats were dealt with successfully, the second century of Ly rule was relatively peaceful enabling the Ly kings to establish a Buddhist ruling tradition closely related to the other Southeast Asian Buddhist kingdoms of that period. Buddhism became a kind of state religion as members of the royal family and the nobility made pilgrimages, supported the building of pagodas, sometimes even entered monastic life, and otherwise took an active part in Buddhist practices. Bonzes became a privileged landed class, exempt from taxes and military duty. At the same time, Buddhism, in an increasingly Vietnamized form associated with magic, spirits, and medicine, grew in popularity with the people.
During the Ly dynasty, the Vietnamese began their long march to the south (nam tien) at the expense of the Cham and the Khmer. Le Hoan had sacked the Cham capital of Indrapura in 982, whereupon the Cham established a new capital at Vijaya. This was captured twice by the Vietnamese, however, and in 1079 the Cham were forced to cede to the Ly rulers their three northern provinces. Soon afterwards, Vietnamese peasants began moving into the untilled former Cham lands, turning them into rice fields and moving relentlessly southward, delta by delta, along the narrow coastal plain. The Ly kings supported the improvement of Vietnam’s agricultural system by constructing and repairing dikes and canals and by allowing soldiers to return to their villages to work for six months of each year. As their territory and population expanded, the Ly kings looked to China as a model for organizing a strong, centrally administered state. Minor officials were chosen by examination for the first time in 1075, and a civil service training institute and an imperial academy were set up in 1076. In 1089 a fixed hierarchy of state officials was established, with nine degrees of civil and military scholarofficials . Examinations for public office were made compulsory, and literary competitions were held to determine the grades of officials.