Third Era of Northern Domination

The Third Era of Northern Domination refers to the third period of Chinese rule in Vietnamese history. The era starts from the end of the Early Lý dynasty in 602 to the rise of the local Khúc family and other Viet warlords in the early 10th century, finally ending in 938 after the defeat of the Southern Han armada by the Viet leader Ngô Quyền. This period saw three Chinese imperial dynasties rule over what is today northern Vietnam: Sui, Tang and Wu Zhou. The Sui dynasty ruled northern Vietnam from 602 to 618, and briefly reoccupied central Vietnam in 605. The successive Tang dynasty ruled northern Vietnam from 621 to 690, and again from 705 to 880. Between 690 and 705, the Tang dynasty was briefly interrupted by the Wu Zhou dynasty which maintained Chinese rule over Vietnam.

Sui rule
By late AD 500s, Jiaozhou (northern Vietnam) was ruled autonomously by a regime of localized Chinese Early Lý dynasty. As the Sui dynasty consolidated power in China, Lý Phật Tử acknowledge Sui overlordship in 589. In 602 when Ly Phat Tu openly rebelled, Emperor Wen of Sui deployed General Liu Fang and 27,000 troops, conquering the region. In 605, Yang Jian pushed further south, invaded the Cham Simhapura kingdom in central Vietnam, briefly set up an administration and divided the country into 3 counties: Tỷ Ảnh, Hải Âm and Tượng Lâm.

Liu Fang was nominated as the viceroy of Jiaozhou. He died while returning from Champa to the north and Qiu He (丘和) replaced him to rule the land. However, in 618, Emperor Gaozu of Tang overthrew the Sui dynasty and established the Tang dynasty. Qiu He first submitted to Xiao Xian's empire in 618, then to the Tang emperor in 622, incorporating northern Vietnam into the Tang dynasty. A local ruler of Jiuzhen (today's Thanh Hóa), Lê Ngọc, stayed loyal to Xiao Xian and fought against the Tang for another three years.

Tang rule
In 627, Emperor Taizong launched an administrative reform which reduced the number of provinces. In 679, Jiaozhou province was replaced with the Protectorate General to Pacify the South (Annan Duhufu). This administrative unit was used by the Tang to govern non-Chinese populations on the frontiers, similar to the Protectorate General to Pacify the West in Central Asia and the Protectorate General to Pacify the East in northern Korea. Every four years, the "southern selection" would choose aboriginal chiefs to be appointed to fill positions of the fifth degree and above. Taxation was more moderate than within the empire proper; the harvest tax was one-half the standard rate, an acknowledgement of the political problems inherent in ruling a non-Chinese population. Native girls of Vietnam: Tais, Viets and others were also targeted by the slave traders. The women of Viet tribes were most likely used as everyday household slaves and handmaidens during most of the Tang.

For the first time since the Han dynasty, Chinese schools were built, and dykes were constructed to protect the capital city of Songping (later Đại La). The Red River delta was the largest agricultural plain in the empire's south, with roads connecting Champa and Zhenla to the south and the southwest, and sea routes connected to the Indian Ocean. Buddhism flourished in Annan, although the Tang's official religion was Daoism. At least 6 monks from northern Vietnam traveled to China, Srivijaya, India and Sri Lanka during the Tang period. Very few natives engaged in the Confucian scholarship and civil service examination.

Revolts and notable events
In 687, the Li chief Lý Tự Tiên rebelled against Tang authority due to the governor of Annan, Liu Yanyou, doubled the taxes. Liu Yanyou killed Lý but couldn't stop the rebellion and was killed. Cao Xuanjing marched into Annan, put down the rebellion, and executed the rebel leader Đinh Kiến.

In 722, Mai Thúc Loan from Jiude (today Hà Tĩnh Province) led a large insurrection against Chinese rule. Styling himself "Swarthy Emperor" or "Black Emperor" (Hắc Đẽ), he rallied 400,000 people from 23 counties to join, and also allied with Champa and Chenla, an unknown kingdom named Jinlin ("Gold Neighbor") and other unnamed kingdoms. A Tang army of 100,000 under general Yang Zixu, including a multitude of mountain tribesmen who had remained loyal to the Tang, marched directly along the coast, following the old road built by Ma Yuan. Yang Zixu attacked Mai Thúc Loan by surprise and suppressed the rebellion in 723. The corpses of the Swarthy Emperor and his followers were piled up to form a huge mound and were left on public display to check further revolts. Later from 726 to 728, Yang Zixu suppressed other rebellions of Li and Nung peoples led by Chen Xingfan and Feng Lin in the north, who proclaimed the title "Emperor of Nanyue", causing another 80,000 deaths.

Because of the An Lushan rebellion in 755, the Annan Protectorate's name was briefly changed to Zhennan Protectorate (guarded south). In 767, the northern Vietnam coast was invaded by Shailendra/Javanese army but was driven back by Chinese general Zhang Boyi. In 785, chieftains of the indigenous, Đỗ Anh Hàn and Phùng Hưng, rebelled due to Tang governor Gao Zhengping's doubling of taxes. Tang forces retook Annan in 791. In 803 and 809, Champa raided southern Annan. Troops working on garrison fortifications also revolted. From 803 to 863, local rebels killed or expelled no fewer than six protector-generals of Annan. In 820, Dương Thanh seized Songping and killed the protectorate general. Dương Thanh was unpopular due to his cruelty and put to death by the locals soon after, however the region continued to experience disorders for the next 16 years.

Nanzhao invasion
In 854, the new governor of Annan, Li Zhuo, provoked hostiles and conflicts with the mountain tribes by reducing the salt trade and killing powerful chieftains, resulting in the defection of prominent local leaders to the Nanzhao Kingdom. The local chief Lý Do Độc, the Đỗ clan, the warlord Chu Đạo Cổ, as well as others, submitted or allied with Nanzhao. In 858 they sacked the capital of Annan. In the same year the Tang court responded by appointing Wang Shi as the military governor of Annan, aiming to restore order, strengthen the defense of Songping. Wang Shi was recalled to deal with the rebellion of Qiu Fu in Zhejiang in late 860. Northern Vietnam then degenerated back to chaos and turmoil. The new Chinese military governor, Li Hu, executed Đỗ Thủ Trừng, a prominent local chief, thus alienating many of the powerful local clans of Annan. The Nanzhao army was initially welcomed by the locals, and their joint force captured Songping in January 861, forced Li Hu to flee. The Tang managed to retake the region in summer 861. In spring 863 Nanzhao and rebels numbered 50,000 under generals Yang Sijin and Duan Qiuqian launched the Siege of Songping. The city fell in late January as the Chinese army withdrew north. The Protectorate of Annan was abolished.

The Tang launched a counterattack in September 864 under Gao Pian, an experienced general who had fought the Türks and the Tanguts in the north. In winter 865–866, Gao Pian recaptured Songping and northern Vietnam, and expelled Nanzhao from the region. Gao punished local people who had allied with Nanzhao, executed Chu Đạo Cổ and 30,000 local rebels. In 868 he renamed the region to "The Peaceful Sea Army" (Jinghai guan). He rebuilt the citadel Sin Songping, named it Đại La, repaired 5,000 meters of damaged city wall and reconstructed 400,000 bays for its residents. He was well respected even by the later Vietnamese.

End of Chinese rule
The Tang continued campaigning against local chieftains in Annan in 874 and 879. In 877, troops deployed from Annan in Guangxi mutined. In 880, the army in Annan mutinied, took the city of Đại La, and forced the military commissioner Zeng Gun to flee, ending de facto Chinese control in Vietnam.

By 880, power was transferred to the local Sino-indigenous elites who governed in the name of Tang. At that point the region was probably still very diverse in terms of ethno-linguistics with a predominance of Kra-Dai and Austroasiatic-speaking peoples, who have since been marginalized by Chinese and Vietnamese histories, as historian and archaeologist John N. Miksic speculates. In 905, a leader named Khúc Thừa Dụ came to power as commissioner for Tĩnh Hải quân (Jinghai guan). The Khúc's origins are unknown but they manipulated the Later Liang dynasty court in the north to maintain their own autonomy. In 930, the emperor of Southern Han Liu Yan attacked Jinghai and removed the Khuc family from power. In late 931, Duong Dinh Nghe, a noble from Aizhou (Thanh Hoa) who was much less sinicized than the Khucs revolted and ousted Southern Han. However Duong Dinh Nghe was assassinated in 937 by a leader of a pro-Chinese faction bent on restoring the sinified leadership he had displaced. Ngo Quyen, son-in-law of Duong, quickly overthrew of the revanchist leaders and defeated the meddling Southern Han fleet in the Battle of Bạch Đằng River in late 938. In 939, he claimed himself king (vua), and chose the ancient town of Co Loa as the court's capital. The Jinghai Circuit became a de facto independent state, and it could be considered that Vietnamese history came into its own at that point.

Viceroy of Jiaozhou

 * Liu Fang
 * Qiu He (-619) under Sui (619-626) under Tang
 * Li Daliang
 * Li Shou
 * Li Daoxing
 * Li Dao’an
 * Li Jian

Duhu of Annam

 * Liu Yanyou 681-687
 * Guo Chuke
 * Abe no Nakamaro 761-767 (Duhu of Zhennan)
 * Wu Chongfu 777-782
 * Li Mengqiu 782
 * Zhang Ying 788
 * Pang Fu 789
 * Gao Zhengping 790-791
 * Zhao Chang 791-802
 * Pei 802-803
 * Zhao Chang 804-806
 * Ma Zong 806-810
 * Zhang Mian 813
 * Pei Xingli 813-817
 * Li Xianggu 817-819 - killed by Yang Qing
 * Yang Qing 819-820 - rebelled and killed by Gui Zhongwu
 * Gui Zhongwu 819-820
 * Pei Xingli 820
 * Gui Zhongwu 820-822
 * Wang Chengbian 822
 * Li Yuanxi 822-826
 * Han Yue 827-828
 * Zheng Chuo 831
 * Liu Min 833
 * Han Wei 834
 * Tian Zao 835
 * Ma Zhi 836-840
 * Wu Hun 843
 * Pei Yuanyu 846-847
 * Tian Zaiyou 849-850
 * Cui Geng 852
 * Li Zhuo 853-855
 * Song Ya 857
 * Li Hongfu 857-858
 * Wang Shi 858-860 (military Jinglueshi during Nanzhao invasions)
 * Li Hu 860-861
 * Wang Kuan 861-862
 * Cai Xi 862-863 (military Jinglueshi)
 * Song Rong 863 (de jure Jinglueshi, Annam invaded by Nanzhao)
 * Zhang Yin 864 (de jure Jinglueshi, Annam invaded by Nanzhao)

Jiedushi of Jinghai

 * Gao Pian 864-866
 * Wang Yanquan 866
 * Gao Xun 868-873
 * Zeng Gun 878-880 (abandoned post due to a rebel)
 * Jing Yanzong (敬彥宗)
 * Gao Maoqing 882-883
 * Xie Zhao (謝肇) 884-?
 * An Youquan 897-900
 * Sun Dezhao 901-?
 * Zhu Quanyu 905
 * Dugu Sun 905

Independent Jiedushi

 * Khúc Thừa Dụ 905-907
 * Khúc Hạo 907-917
 * Khúc Thừa Mỹ 917-930
 * Dương Đình Nghệ 931-937 (self-proclaimed)
 * Kiều Công Tiễn 937-938 (self-proclaimed)

Culture and religion
Revival of direct Tang control over northern Vietnam for two centuries resulted in a hybrid Tang-indigenous culture, political and legal structures. Local sinicized elites used Chinese script, and ordinary people and tribesmen adopted personal names and name styles that corresponded to Vietnamese personal names until now. A large number of Chinese officers and soldiers were sent to northern Vietnam, some of whom married Vietnamese women and settled down. Buddhism thrived in northern Vietnam throughout the Tang era. Some of Chinese monks came and taught Chinese Buddhism in Annan. Wu Yantong (d. 820), a prominent Chinese monk in northern Vietnam, brought a new sect of Chan Buddhism that survived for about five centuries. Vietnamese women had large roles and status in religious life and society. Buddhist texts were written in Chinese, and recited with Vietnamese pronunciation. Vietnamese temples and monasteries differed with Chinese and other East Asian countries in their role as the đình, the village spiritual center, where village elders met.

Indigenous Confucianist scholarly elites remained very relatively small. In 845, a Tang official reported to the throne that "Annan has produced no more than eight imperial officials; senior graduates have not exceeded ten." Liêu Hữu Phương was the only recorded student from Northern Vietnam to have passed the classical exams in 816 in the Tang capital of Chang'an. He succeeded on his second attempt and became a librarian at the imperial court.