Annan (Tang protectorate)

Annan () was the southernmost province of Tang China from 679 to 866. Annam is the Vietnamese form of the Chinese name Annan, which means "the Pacified South" or "to pacify the South", a clipped form of the full name, the "Protectorate General to Pacify the South" . In 679, the Annan Protectorate replaced the Jiaozhou Protectorate () (), also known as Jiaozhi, with its seat situated in Songping County () (modern Hanoi). Annan was renamed to Zhennan for a brief period from 757-760 before reverting to Annan. After coming under attack by Nanzhao in 864, the Annan Protectorate was renamed Jinghai Military Command upon its reconquest by Gao Pian in 866. Today the same area is sometimes known as Tonkin (), the "eastern capital" of Đại Việt. Locally, the area is known as (), the "northern area".
History.
Predecessors.
The territory was conquered for the Qin dynasty by Zhao Tuo after the death of Qin Shi Huang. In the chaos surrounding the Chu–Han Contention, he declared its independence as Nanyue and ruled from Panyu (modern Guangzhou). Jiaozhou was the Han dynasty country subdivision formed from the annexation of this tributary kingdom in 111 BCE and it initially comprised the areas of modern Guangdong, Guangxi, and northern Vietnam.
During the Three Kingdoms era, Eastern Wu split from Liangguang as Guangzhou in 222 CE. Tang rule in northern Vietnam began in 622 after Qiu He, the Chinese warlord recognized Tang authority.
Tang Protectorate.
In 624 the Tang dynasty created the Jiaozhou Protectorate. In 627 the Jiaozhou Protectorate was put under the administration of Lingnan Circuit. In 679, the Annan Protectorate replaced the Jiaozhou Protectorate and was seated in Songping County () in present day Hanoi. The Annan Protectorate was renamed Zhennan Protectorate in 757. It was changed back to Annan Protectorate in 760. The Annan Protectorate came under attack from Nanzhao in 846 and the conflict lasted until 866, after which the Jinghai Army Jiedushi was created. 
List of notable events.
In 676, jiedushi and governors of Guangxi, Guangdong and Jiaozhou established a method of selecting local men for administrative positions. 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.
In 687, the new governor of Annan, Liu Yanyou doubled the taxes. The Viet peasants under chief Lý Tự Tiên resisted. Liu Yanyou killed Lý. Đinh Kiến, one of Lý's compatriots, led the people against Yanyou and besieged him in Songping. In the summer, the rebels took Songping and put Yanyou to death. A governor general, Feng Yuanchang, had earlier been called in to help Liu, but Feng hoped to gain influence at Liu's expense and did nothing to help him. Instead Feng established a fortified camp and sent envoys to the rebels telling them to kill their leader and join him. After Liu was killed, Feng abandoned Annan. Another general, Cao Xuanjing, marched into Annan, put down the rebellion, and executed Đinh Kiến.
In 694, Lao tribesmen in Guangxi rebelled. The rebellion was quickly putdown.
In 722, Mai Thúc Loan rebelled in what is now Hà Tĩnh Province and proclaimed himself the "Swarthy Emperor" or "Black Emperor" (Hắc Đẽ). His rebellion rallied people from 23 counties with "400,000 followers". Many were peasants who roamed the countryside, plundering food and other items. He also allied with Champa and Chenla, an unknown kingdom named Jinlin (“Gold Neighbor”) and other unnamed kingdoms. A Chinese army of 100,000 from Guangdong 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.
In 767, Srivijaya fleets invaded Annan and were defeated.
In 785, chieftains of the Annamese, Đỗ Anh Hàn, Phùng Hưng and Phùng An rebelled, due to Chinese governor Gao Zhengping's doubling of taxes. Tang forces retook Annan in 791.
In 803,Champa seized 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 (Yang Qing) seized Đại La 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. 
From 823 to 826, the Nung people (Huang people), aided by raiders from Champa, attacked Yongzhou and seized 18 counties. These raiders, known as the barbarians of the "Nung Grottoes" (Yellow Grotto Barbarians), sought aid from Nanzhao after the Tang retaliated from 827-835.
In 845 Wu Hun tried to get his troops to rebuild the city walls but they rebelled and forced him to flee. The rebellion was put down.
In 846 barbarians raided Annan. Pei Yuanyu counterattacked with soldiers from neighboring provinces.
Rebellion, invasion, and renaming.
In 854 the new Jiedushi of Annan, Li Zhuo, provoked conflict with the mountain tribes by reducing the salt trade and killing powerful chieftains, resulting in the defection of prominent local leaders to Nanzhao. The general Lý Do Độc, as well as others, submitted to Nanzhao. In 858, Nanzhao invaded Annan while new jiedushi, Li Hu, killed the son of a chieftain who was implicated in a mutiny, further alienating powerful clans in Annan and causing them to defect to Nanzhao. While Nanzhao invaded in earnest, the Đỗ clan rebelled with 30,000 men. There was general chaos as Nanzhao ravaged Annan, alienating the locals, and the balance of power see-sawed between Tang and Nanzhao forces. In 864, the experienced Tang general, Gao Pian, led a counterattack that saw the defeat of Nanzhao forces in 866. He recaptured Songping, the capital of Annan, and named the rebuilt capital Đại La. He also renamed the region of Annan to Jinghai Jun (lit. Peaceful Sea Army).
Aftermath.
A campaign against local aboriginals in Annan was conducted from 874-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.
Culture and religion.
During the era of the Annan Protectorate, the people now known as the Vietnamese had no particular name. They were referred to in Chinese writing as the "Wild Man" (Wild Barbarians), the "Li" or the Annamese. Since antiquity they had been noted for their tattooing and cropped hair, wearing line ponchos ("yếm"), wielded wooden spears, and shot boneheaded arrows. They also sacrified men to their agricultural gods. In the north, around Yongzhou (Nanning), near modern-day Guangxi, mountains were the territories of the Huang (Ghwang) people or the "Grotto Barbarians", the Nùng people and the Ning clans.
Revival of direct Tang control over Annan for two centuries resulted in a hybrid Tang-Vietnamese culture, political and legal structures. Local sinicized elites used Chinese script, and ordinary people and tribesmen adopted personal names and name styles that corresponding to Vietnamese personal names until now. A large number of Chinese officers and soldiers were sent to Annan, some of whom married Vietnamese women and settled down. Buddhism thrived in Annan throughout the Tang era. Some of Chinese monks came and taught Chinese Buddhism in Annan. Wu Yantong (d. 820), a prominent Chinese monk in Annan, 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. The famous Tang Chinese monk Yijing mentioned six Vietnamese monks who went on pilgrimage to India and Ceylon in search of the Dharma. Although Daoism became the dynasty’s official religion, four prominent Tang poets praised Buddhist masters who hailed from Annan. 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 Vietnamese student 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.