# Hoàng Kế Viêm

Hoàng Kế Viêm (1820–1909) was a Vietnamese General and a Dong'ge Grand Secretariat during the Nguyễn dynasty. He played a significant role in suppressing borderlands banditry and resisting French invasion during the second half of the 19th century.

## Early years

Hoàng Kế Viêm (1820–1909) was a son-in-law of emperor Minh Mạng. His father is Hoàng Kim Xán, the governor of province Khánh Hòa. In the year 1841, Emperor Minh Mạng died, and his eldest son Thiệu Trị succeeded to the throne.
In 1843, Hoàng Kế Viêm married Nguyễn Phúc Quang Tĩnh, the fifth daughter of Emperor Minh Mạng and thus became a Prince (Phò mã). The next year, Nguyễn Phúc Quang Tĩnh died at age 28 during pregnancy. Emperor Thiệu Trị gave her the title of Princess Hương La (Hương La Công Chúa).

## Military career
### Anti-Imperial Bandits
#### Yanling Kingdom

In 1849, Taiping Rebellion broke out by Hong Xiuquan, together with Yang Xiuqing, Xiao Chaogui and Li Xiucheng. They later took control of Jinling and provinces south of the Yangtze River. In 1857, Liu Yongfu, the future founder of Black Flags, joined Wu Lingyun (Wu Yuanqing) who led uprisings and rebellions against Qing dynasty in Guangxi province. In 1861, Wu Lingyun formed the Kingdom of Yangling in southern Guangxi. Unlike millenarian Christianity of Taiping, Yanling kingdom did not ask his followers to choose a religious agenda. According to Trần Trọng Kim, Wu Lingyun's son Wu Kun (Wu Yazhong) was the follower of Taiping Heavenly Rebellions, while Henry McAleavy described Wu Lingyun (Wu Yuanqing) as “freebooter” taking advantage of Taiping Heavenly's prestige and absence in Guangxi after Taiping Rebellion established itself in Nanking as a dynasty. Bradley C. Davis recently further explained that Yanling kingdom and Taiping Heavenly Kingdom were two separate movements.
In 1863, Wu Lingyun (Wu Yuanqing) died when having battle with Guangxi provincial army led by Feng Zicai, which pushed Yanling kingdom into crisis. His son Wu Yazhong (also called Wu Kun) became the new leader and led his loyalists to occupied Guishun, a city in the far west of Guangxi. During this time, Wu Yazhong kept seeking followers, while Liu Yongfu decided to leave China for Vietnam with his followers whom he gathered and formed Black Flags.

#### White Flags and Black Flags

Before Liu Yongfu's arrival, White Flags, a bandit from southern China, has been raided in northern Vietnam for many years. Another saying is, White Flags was also the former follower of Wu Lingyun. In 1866, Huế court assigned Nguyễn Bá Nghi to negotiate the surrender of White Flags. Nguyễn Bá Nghi disagreed with the idea of giving the bandit leader a position in order to make use of their strength, insisting on conventional way by strengthening military power, but he failed.
Planning to confront White Flags, Liu Yongfu formed an alliance with Deng Wan, another bandit from southern China. In February 1868, White Flags took control of Lục Yên. Liu Yongfu, who just arrived in Vietnam, was planning to lay siege to Lục Yên. In March, Black Flags captured Lục Yên. The leader of White Flags, Bàn Văn Nhị, was decapitated. Liu Yongfu thus received official position from Vietnamese authorities.

#### Wu Yazhong and Yellow Flags

In pursuit of Liu Yongfu, Wu Yazhong entered Vietnam after Black Flags defeated White Flags rebellion. Pan Lunsi (also called Huang Chongying or Hoàng Sùng Anh), Wu Yazhong's lieutenant as well as his nephew, founded Yellow Flags and led them to Hà Dương, the former stronghold of White Flags. Their target was Vietnamese authorities. In March 1868, Wu Yazhong and Yellow Flags waged an attack on Cao Bằng. In October 1868, Yellow Flags conducted raids in Tuyên Quang. Phạm Chi Hương was appointed to organize a campaign against Wu Yazhong with the assistance of Ông Ích Khiêm. In July 1868, Vietnamese army was defeated in Lạng Sơn.
Qing dynasty appointed Feng Zicai to suppress Wu Yazhong in Vietnam. At the same time, Huế court also promoted Võ Trọng Bình to borderlands patrol commissioner who would serve as the link between Huế court and Feng Zicai. Feng Zicai's strategy which funded local militia to build up a “trap” for Wu Yazhong in the northern borderlands was cost-effective but successful. In late 1869, Wu Yazhong fled into Thái Nguyên and died there because of heavy wound. Another saying is that Wu Yazhong was killed by Ông Ích Khiêm when laid siege to Bắc Ninh in 1870. After Wu Yazhong's death, Yellow Flags and Black Flags were all that remained of Yanling Kingdom. Through levying taxation in opium trade and conducting pillages, these two bandits controlled the northern Vietnam. Later a brief battle happened between Yellow Flags and Black Flags, ending with Yellow Flags’ expulsion from Lào Cai.

#### Hoàng Kế Viêm and Imperial Bandits

To solve the bandit problems in the borderlands, Đoàn Thọ was appointed as President of Tonkin military service. When Đoàn Thọ arrived at Lạng Sơn, a bandit named Tô Tứ sneaked on Lạng Sơn at midnight and killed Đoàn Thọ, while Võ Trọng Bình fled. In 1870, the Vietnamese court immediately assigned Hoàng Kế Viêm as governor of Lạng Sơn, Thái Bình and Ninh Bình to suppress banditry in northern Vietnam together with Tôn Thất Thuyết.
In the same year (1870), Pan Lunsi took control of his former base at Hà Dương in Tuyên Quang and later waged attack on Vietnamese soldiers. After defeating provincial government, the Yellow Flags occupied Tuyên Quang, threatening the Black Flags from east of Lào Cai. The action of Pan Lunsi stimulated heated debate in Huế court. Some mandarins were suspicious about the employment of Black Flags, but the court confirmed the official status of Liu Yongfu. When Pan Lunsi offered surrender twice to Huế court in 1871 and 1872, Hoàng Kế Viêm, the Black Flags’ supervisor, relayed the Vietnamese court's refuse of negotiation with Yellow Flags.
After killing Francis Garnier in 1873 when he attacked Hanoi, Liu Yongfu received a promotion to vice military commander in Vietnamese bureaucracy. Later in 1874, Hoàng Kế Viêm was appointed as governor-general of Sơn-Hưng-Tuyên and Tôn Thất Thuyết served as governor of Sơn Tây and consoler for military affairs. These two officials, together with Liu Yongfu, continued their struggle with Pan Lunsi and Yellow Flags which was the prior concern of Huế court. In early 1874, they sent out armies to chase after Yellow Flags from Tuyên Quang. In September, Pan Lunsi offered his surrender letter to Hoàng Kế Viêm, but the court still showed no interest and ordered governor of Hừng Hoa to demand Black Flags to capture Pan Lunsi. In March 1875, Huế court, refusing China's assistance in the war with Yellow Flags before, accepted Chinese help, appointed Tôn Thất Thuyết to cooperate with Qing military against Yellow Flags. Qing's army, led by Li Yangcai and Liu Yucheng, flushed most Yellow Flags out of Thái Nguyên, while Black Flags and Vietnamese military waited them in Hà Dương, the old base of Yellow Flags. The war ended with Pan Lunsi's mutilation and dismemberment. In 1878, Liu Yongfu began to receive monthly salary and supplies from Huế court as reward to his victory over the Yellow Flags. But not all the imperial officials accepted the Black Flags. Hoàng Kế Viêm, as the liaison between the court and Black Flags, encouraged Liu Yongfu and his men to cultivate land around Lào Cai so that he could not only mollify the critics towards Black Flags from imperial officials but also control the imperial bandit by binding them in one location. But his plan failed for Liu Yongfu had no interest in land cultivation or leaving Lào Cai. Later in March 1878, Black Flags conducted raids in Hưng Hóa province. At the same time, officials in Hanoi required a full report of Liu Yongfu’ actions through the court. Hoàng Kế Viêm promised to have a full investigation into Liu Yongfu, providing the account of his alleged crimes against Vietnamese authorities.

### French Invasion
#### French first attack on Tonkin (1873)

In 1860s, Jean Dupuis, a French gun dealer, planned to sell his weapons to China where internal rebellions were happening. When Yunnan provincial military commander Ma Rulong was willing to purchase a shipment of rifles and ammunition, Dupuis decided to deliver these weapons by ships sailing from Hong Kong to Vietnam where he could use Red River to travel to Yunnan. With the help of Marcel Dupré, the governor-general of Cochinchina and the recognition of French Ministry of Navy, Dupuis prepared ships and crew, leaving Hong Kong in October 1872. During his journey, he had no fear of Vietnamese authorities for he had acquired a contract with Yunnan administration and a well-armed commercial vessel that every time he ignored the official orders to wait, directly leaving for next city. He exchanged foods and other materials with his weapons. He even met with Pan Lunsi and developed a close relationship with Yellow Flags. Hoàng Kế Viêm, in the middle of fighting against Yellow Flags with Feng Zicai and Black Flags, ordered officials to follow Dupuis, trying to detain him in Hưng Hóa. When Dupuis arrived in Yunnan, his contact with Yellow Flags was known by Huế court, and he was detained when he later returned to Hanoi.
Since French colonial controlled Cochinchina, French have been scouting Tonkin and Annam in order to find a path into China. In 1866, Francis Garnier joined Doudard de Lagree’s expedition to search for a way to China along Mekong River. Even though the road through Mekong failed, Garnier remarked that it was possible to use Red River as commercial link between Cochinchina and Yunnan.
As Jean Dupuis was detained, Francis Garnier returned to Cochinchina. Admiral Dupré assigned him the task to negotiate the release of Dupuis. Garnier presented a list of demands to the court, waiting for response, while Huế court did not take any action, suspicious of Garnier’s real intention. Because of that, Francis Garnier decided, without permission from his superior, to take over Hanoi by force on 20 November 1873. After capturing the city, Garnier and his men launched themselves in a full blown conquest of the region and conquered most of the delta's largest cities in the course of December 1873. There was divergence between Huế court and regional military officials. On the one hand, Huế court was preparing for negotiation with French representative to have Garnier remove from Hanoi. On the other hand, Hoàng Kế Viêm ordered Liu Yongfu and Black Flags to move to west of Hanoi, ready for offensive. On 21 December, a battle was started and ended with the decapitation of Francis Garnier by Black Flags’ platoon. The moment Huế court was informed of Garnier's death, court officials ordered Hoàng Kế Viêm and Tôn Thất Thuyết to move Liu Yongfu back to Hưng Hóa.
About Francis Garnier's death, there are different opinions. In 1973, Adrien Balny d’Avricourt wrote that the fatal attack on Garnier by Black Flags pirates was urged by the court which had never failed to apply the policy of duplicity. While the Vietnamese Veritable Records Dai Nam thuc luc recorded, Emperor Tự Đức’s intention was to solve the crisis with negotiation, and his order to Hoàng Kế Viêm and Tôn Thất Thuyết to prepare for military actions was reluctant and out of his distrust to French people. Hoàng Kế Viêm and Tôn Thất Thuyết were acting with deliberate calculation when they made sure that Liu Yongfu would cooperate and encouraged him to launch the attack, which exceeds the authority.
Though Garnier had been killed, the attack to retake Hanoi had failed and the French remained in control of the Red River Delta. However, the French government disapproved the unauthorized conquest and thus a second French expedition was sent to remove Garnier's men from the cities they occupied and repatriate them back to Saigon. In March 1874, a treaty of negotiation was facilitated, and Dupuis was evacuated. This treaty also called Philastre Treaty which introduced some changes to the French presence in Vietnam including the establishment of two consulate offices in Hanoi and Hai Phong. In return, France provided material goods like weapons and ships to Huế court.

#### Tonkin Campaign

After the establishment of French consulates in Hanoi and Hai Phong, de Kergaradec, French consul in Hanoi, began to scout northern Vietnam and collected Vietnamese information about resources, intending to open the commerce and water way in Red River Delta controlled by bandits, but they encountered many difficulties. He agreed that banditry in the north, especially Black Flags, was the biggest obstacle to free commerce through Red River. De Kergaradec was not the only person holding the thought. In 1881, Henri Rivière became commandant de la division in Cochinchina. He Arrived at Hanoi on April 10, 1882. The governor of Cochinchina Le Myre de Vilers also considered Liu Yongfu and his Black Flags as pirates threatening lawful commercial activities.
At that moment, Liu has detained two mining engineers sent by de Kergaradec to chart the mining resources of Vietnam. De Vilers claimed that if Huế court could not put into effect the provisions of treaty of 1874 about Black Flags and release the French engineers, he would send French forces north. In response, Liu Yongfu declared his note on Hanoi citadel on March 26, 1883, which threatened to kill Henri Rivière.
Worried about the possible conflict with Rivière, Huế court ordered Hoàng Kế Viêm and another mandarin Nguyễn Hữu Độ, who strongly distrusted Black Flags, to investigate Liu Yongfu and his men. To deprive Rivière of a pretext of hostility, the court also commanded Hoàng Kế Viêm to move Black Flags away from Hanoi. But these seemed useless. After less than ten days, Rivière sent a letter to Hanoi provincial military commander Hoàng Diệu, forcing him to guarantee either the submission or eradication of Black Flags, otherwise he would seize Hanoi. Apparently, it was impossible for Hoàng Diệu to do that. Therefore, on April 26, 1883, Rivière occupied Hanoi. Huế court immediately placed Nguyễn Hữu Độ in negotiation with France, while Hoàng Kế Viêm prepared for war in northern provinces. Conflict inside the court about Black Flags was intensified. Hoàng Kế Viêm accused Nguyễn Hữu Độ of failing to provide promised funds for Black Flags to return to Lào Cai from Hanoi. Another high-ranking official named Trần Đình Túc also opposed to Black Flags and Hoàng Kế Viêm though for different reasons.
In negotiation, Huế court refused to grant authorization for a French outpost in Sơn Tây, defending the interests of Black Flags. This action, in Rivière's mind, was a signal of hostility. He considered Hoàng Kế Viêm's relationship with Black Flags as a corrosive influence on other officials to ignore French demands. What's worse to Rivière was that by August 1882, he was limited by French authorities in Cochinchina to a defensive role, but he kept detaining all Chinese soldiers discovered in French-controlled Vietnamese territory. To ease French anxiety, Vietnamese mandarin Bùi Văn Dị proposed to the court that Hoàng Kế Viêm should write to French consulate in Hanoi to explain the official role of Black Flags, hoping for an opening for negotiation of the return of Hanoi. Despite the plea for negotiation, Hoàng Kế Viêm and Black Flags continued to prepare for war.
In early 1880s, China tended to believe that French invasion of Hanoi and Red River Delta was a beginning of invading southern China for Qing authorities in Guangxi province detained a questioned a man called Li Yuchi, who they believed had a furtive relationship with France. The Grand Council started to think about forming an alliance with Black Flags in defense of Chinese borderlands. Therefore, in April 1882, following the capture of Hanoi by Rivière, Yunnan and Guangxi military were sent to northern Vietnam. In January 1883, a Qing official called Tang Jingsong began his travel in Vietnam, planning to personally contact Liu Yongfu and enlist his Black Flags in the coming war against France.
On February 28, 1883, Rivière began launching attack on Nam Định. French army entered the town by noon. The governor Võ Trọng Bình fled. Later, he was demoted and criticized for exceeding the court's limitation on salary provisions for Chinese soldiers when he tries to enhance the defenses of Nam Định. After the capture of Nam Định, Tang Jingsong traveled to Sơn Tây where he made contact with Hoàng Kế Viêm. Later, Tang Jingsong finally met Liu Yongfu thanks to Hoàng Kế Viêm. During the meeting, Hoàng Kế Viêm talked about an offensive to Saigon in response to Rivière's invasion of Nam Định. He proposed that an invasion to Saigon would disrupt the connection between Saigon and Paris and even imperil French supply line. Meanwhile, Tang Jiangsong also transmitted Qing empire's will to offer materials and official title to Liu Yongfu in exchange of his loyalty to China. Deeming the recapture of Nam Định impossible, Hoàng Kế Viêm and Liu Yongfu left Tang Jingsong in Sơn Tây and moved their soldiers to the village west to Hanoi.
On May 19, 1883, Henri Rivière and his French expeditionary force left Hanoi for Black Flags’ camps. Black Flags’ scouts noticed them and informed Liu Yongfu. A fatal attack waged by Black Flags wounded Rivière heavily and he died. Rivière's head was displayed outside the west gate of Hanoi the next morning. On May 27, Paris government sent a telegram to the governor of Cochinchina, “France shall revenge her brave children.” Alexandre-Eugène Bouët, who was in Cochinchina during this time, was appointed as military commander in Tonkin. On August 16, 1883, Bouët took Hải Dương and forced Black Flags to retreat to Paper Bridge (Cầu Giấy). But the terrible weather precluded further operations, so Bouët went back to Hanoi and asked France for more troops. At the same time, Jules Harmand, together with Anatole-Amédée-Prosper Courbet, moved to south to force Huế court to accept French protection in Tonkin and Annam. Emperor Hiệp Hòa was forced to negotiate. On September 25, 1883, imperial officials Trần Đình Túc and Nguyễn Trọng Hợp signed the Harmand Treaty. Huế court could still govern central Vietnam without interference from France except in matters of customs. Tôn Thất Thuyết and Nguyễn Văn Tường executed Emperor Hiệp Hòa, showing their opposition. Meanwhile, Hoàng Kế Viêm was instructed to secretly close his ranks with Chinese in Sơn Tây.

#### Sino-French War

In December 1883, a second attack on Sơn Tây was waged. This time, five battalions of Chinese soldiers joined Black Flags. Courbet believed that there were as many as 25,000 soldiers waiting for him, but the fact is that only a few Chinese soldiers assisting Black Flags in Sơn Tây. At the end, Tang Jingsong fled with Vietnamese officials’ help. Sơn Tây fell to France.
After the fall of Sơn Tây, Black Flags retreated to north of Hanoi. The next attack of France came soon. French general Charles-Théodore Millot, together with another two French generals, launched an attack on Bắc Ninh. Blak Flags and Chinese ally Xu Yanxiu withdrew to Hưng Hóa. Tang Jingsong also followed Liu Yongfu, fleeing to Hưng Hóa. The fall of Bắc Ninh has consequences to Xu and Tang. They were considered culpable of the fall of Bắc Ninh by China and they were called to capital for a full investigation. In April, Xu Yanxiu died in custody, while Tang Jingsong, after learning in January 1884 of the reduction of his punishment to life imprisonment, passed away in Beijing.
French army kept pushing Black Flags all the way to Lào Cai. In May 1884, General Millot declared French victory in Tuyên Quang. On May 11, 1883, Li Hongzhang and Ernest Fournier signed the Li-Fournier Convention, confirming that Qing Empire would remove military from Vietnam, make sure the safety of borderlands and be willing to new commercial treaties with France, while France guaranteed naval protection of coastal waters in south-China sea and northern Vietnam. Following was the Treaty of Huế which confirmed that a representative of Third Republic would directly interact with Vietnamese court. During negotiation, the court also issued a general recall of officials. Nguyễn Quang Bích, along with many officials serving with Black Flags, refused to comply. However, in the spring of 1884, Hoàng Kế Viêm returned to Huế court as commanded. The former powerful official was demoted as the supervisor of Ministry of Public Works under supervision of French protectorate. Hoàng Kế Viêm's trust towards the court led to his punishment by the colonial regime.

#### Cần Vương Movement

After the death of Emperor Hiệp Hòa, Tôn Thất Thuyết and Nguyễn Văn Tường placed Nguyễn Ưng Lịch on the throne as Emperor Hàm Nghi in July 1885. They started to plan for an opposition towards French protectorate led by this new Emperor. But not all the elites participated the rebellion, including Nguyễn Văn Tường and Hoàng Kế Viêm. Despite his role in selecting Emperor Hàm Nghi, Nguyễn Văn Tường was unwilling to answer the call of revolt. French general de Courcy demanded Nguyễn Văn Tường to capture his former ally, Tôn Thất Thuyết. Failing to do that, Nguyễn Văn Tường was deported to island prison at Poulo Condore en route to Tahiti. Hoàng Kế Viêm had retired to his hometown in Quảng Bình after demotion.
After Nguyễn Văn Tường was exiled, Nguyễn Phúc Biện was enthroned as Emperor Đồng Khánh. But there were still many followers of Emperor Hàm Nghi. French general Chaumont was appointed to lead force into Quảng Bình to stop Tôn Thất Thuyết from going back to Tonkin. In 1886, Emperor Đồng Khánh began his northern tour to Quảng Bình, planning to convince Emperor Hàm Nghi and his followers to pay allegiance, but he failed. The same year, Emperor Đồng Khánh came back to Huế safely. Later he reinstated Hoàng Kế Viêm as Dong’ge Grand Secretariat, ordered him to convince Emperor Hàm Nghi and his followers to pay allegiance. But Hoàng Kế Viêm acquired no much success, coming back to court in 1887.
In 1888, French army came to Quảng Bình, in search of Emperor Hàm Nghi. One of his followers betrayed and exposed Emperor Hàm Nghi's position. Therefore, Emperor Hàm Nghi was captured. Knowing the capture of Hàm Nghi, Tôn Thất Đàm, son of Tôn Thất Thuyết, committed suicide.