The sixth century was an important stage in the Vietnamese political evolution toward independence. During this period, the Vietnamese aristocracy became increasingly independent of Chinese authority, while retaining Chinese political and cultural forms. At the same time, indigenous leaders arose who claimed power based on Vietnamese traditions of kingship. A series of failed revolts in the late sixth and early seventh centuries increased the Vietnamese national consciousness. Ly Bi, the leader of a successful revolt in 543 against the Liang dynasty (502-556), was himself descended from a Chinese family that had fled to the Red River Delta during a period of dynastic turbulence in the first century A.D. Ly Bi declared himself emperor of Nam Viet in the tradition of Trieu Da and organized an imperial court at Long Bien. Ly Bi was killed in 547, but his followers kept the revolt alive for another fifty years, establishing what is sometimes referred to in Vietnamese history as the Earlier Ly dynasty.
While the Ly family retreated to the mountains and attempted to rule in the style of their Chinese overlords, a rebel leader who based his rule on an indigenous form of kingship arose in the Red River Delta. Trieu Quang Phuc made his headquarters on an island in a vast swamp. From this refuge, he could strike without warning, seizing supplies from the Liang army and then slipping back into the labyrinthine channels of the swamp. Despite the initial success of such guerrilla tactics, by which he gained control over the Red River Delta, Trieu Quang Phuc was defeated by 570. According to a much later Vietnamese revolutionary, General Vo Nguyen Giap, Vietnamese concepts of protracted warfare were born in the surprise offensives, night attacks, and hit-and- run tactics employed by Trieu Quang Phuc.
The Chinese Tang dynasty (618-907) instituted a series of administrative reforms culminating in 679 in the reorganization of Vietnamese territory as the Protectorate of Annam (or Pacified South), a name later used by the French to refer to central Vietnam. The Tang dynastic period was a time of heavy Chinese influence, particularly in Giao Chau Province (in 203 the district of Giao Chi, had been elevated to provincial status and was renamed Giao Chou), which included the densely populated Red River plain. The children of ambitious, aristocratic families acquired a classical Confucian education, as increased emphasis was placed on the Chinese examination system for training local administrators. As a result, literary terms dating from the Tang dynasty constitute the largest category of Chinese loan words in modern Vietnamese. Despite the stress placed on Chinese literature and learning, Vietnamese, enriched with Chinese literary terms, remained the language of the people, while Chinese was used primarily as an administrative language by a small elite. During the Tang era, Giao Chau Province also became the center of a popular style of Buddhism based on spirit cults, which evolved as the dominant religion of Vietnam after the tenth century. Buddhism, along with an expanding sea trade, linked Vietnam more closely with South and Southeast Asia as Buddhist pilgrims traveled to India, Sumatra, and Java aboard merchant vessels laden with silk, cotton, paper, ivory, pearls, and incense.
As Tang imperial power became more corrupt and oppressive during the latter part of the dynasty, rebellion flared increasingly, particularly among the minority peoples in the mountain and border regions. Although the Viet culture of Giao Chau Province, as it developed under Tang hegemony, depended upon Chinese administration to maintain order, there was growing cultural resistance to the Tang in the border regions. A revolt among the Muong people, who are closely related to the central Vietnamese, broke out in the early eighth century. The rebels occupied the capital at Tong Binh (Hanoi), driving out the Tang governor and garrison, before being defeated by reinforcements from China. Some scholars mark this as the period of final separation of the Muong peoples from the central.
Vietnamese, which linguistic evidence indicates took place near the end of the Tang dynasty. In the mid-ninth century, Tai minority rebels in the border regions recruited the assistance of Nan-chao, a Tai mountain kingdom in the southern Chinese province of Yunnan, which seized control of Annam in 862. Although the Tang succeeded in defeating the Nan-chao forces and restoring Chinese administration, the dynasty was in decline and no longer able to dominate the increasingly autonomous Vietnamese. The Tang finally collapsed in 907 and by 939 Ngo Quyen, a Vietnamese general, had established himself as king of an independent Vietnam.