Tây Sơn dynasty
The name Tây Sơn (,  家西山, Hán Việt: 西山朝 Tây Sơn triều) is used in Vietnamese history in various ways to refer to the period of peasant rebellions and decentralized dynasties established between the end of the figurehead Lê dynasty in 1770 and the beginning of the Nguyễn dynasty in 1802.  The name of the rebel leaders' home district, Tây Sơn, came to be applied to the leaders themselves (the Tây Sơn brothers: i.e., Nguyễn Nhạc, Huệ, and Lữ), their uprising (the Tây Sơn Uprising) or their rule (the [Nguyễn] Tây Sơn dynasty).

Background 

During the 18th century, Vietnam was under the nominal rule of the officially revered, but politically powerless Lê dynasty. Real power was in the hands of two warring feudal families, the Trịnh lords of the north who controlled and ruled from the imperial court in Hanoi and the Nguyễn lords in the south, who ruled from their capital Huế. Both sides fought each other for control of the country while claiming to be loyal to the emperor. Life for the peasant farmers was difficult. Ownership of land became more concentrated in the hands of a few landlords as time passed. The Mandarin bureaucracy was oppressive and often corrupt; at one point, royal-sanctioned degrees were up for sale for whoever was wealthy enough to purchase them. In contrast to the people, the ruling lords lived lavish lifestyles in huge palaces. The decades-long war between the Trịnh and the Nguyễn had ended in 1672 and life for the northern peasants was fairly peaceful. However, the Nguyễn Lords engaged in a regular series of wars with the weak Khmer Empire, and later, the fairly strong state of Siam. While the Nguyễn usually won, and despite the fact that the new lands they conquered offered new opportunities for the landless poor, the frequent wars took a toll on their popularity.

Conquest of Nguyễn lord
In 1769, the new king of Siam, King Taksin, launched a war to regain control of Cambodia. The war generally went against Nguyễn lords and they were forced to abandon some of the newly conquered lands, which included Cambodia's Eastern Coast (Cochin China). This failure, coupled with heavy taxes and corruption at the local level, caused three brothers from the village of Tây Sơn to begin a revolt in 1772 against Lord Nguyễn Phúc Thuần.

The Tây Sơn brothers styled themselves as champions of the people. Over the next year, the revolt gained traction and they won some battles against the Nguyễn army units sent to crush their rebellion. The Tây Sơn had a great deal of popular support, not only from the poor farmers but from some of the indigenous highland tribes. The leader of the three brothers, Nguyễn Huệ, was also a very skilled military leader. Nguyễn Huệ said that his goal was to end the people's oppression, reunite the country, and restore the power of the Lê emperor in Hanoi. The Tây Sơn also promised to remove corrupt officials and redistribute land.

In 1773 the Tây Sơn captured the port of Qui Nhơn, where the merchants, who had suffered under restrictive laws put in place by the Nguyễn, gave the uprising financial support. The Nguyễn, at last recognizing the serious scale of the revolt, made peace with the Siamese, giving up some land they had conquered in previous decades. However, their problems were compounded when Trịnh Sâm chose to end the 100-year peace and exploit the turmoil in the south by sending his army to attack Phú Xuân (modern-day Huế), the Nguyễn capital. The Trịnh army captured the city, forcing the Nguyễn to flee to Gia Định (later called Saigon).

The Trịnh army continued to head south and the Tây Sơn army continued its conquest of other southern cities. The Nguyễn were unpopular at this time, and the forces against them were too powerful. In 1776, the Tây Sơn army captured the last Nguyễn stronghold of Gia Định and massacred the town's Han Chinese population. The entire Nguyễn family was killed at the end of the siege, except for one nephew, Nguyễn Ánh, who managed to escape to Siam. The eldest Tây Sơn brother, Nguyễn Nhạc, proclaimed himself Emperor in 1778. A conflict with the Trịnh thus became unavoidable.

Defeat of Siam 
The Tây Sơn spent the next decade consolidating their control over the former Nguyễn territory. Nguyễn Ánh proved to be a stubborn enemy. He convinced the King of Siam, P'ya Taksin, to invade Vietnam in support of him. The Siamese army attacked in 1780, but in several years of warfare, it was unable to defeat the Tây Sơn army, as gains were followed by losses. In 1782, the Siamese king was killed in a revolt, and less than a year later, Nguyễn Ánh's forces were driven out of Vietnam. In 1785, Siam launched an invasion again and occupied part of the Cuu Long Delta, but was defeated by Nguyen Hue in the Battle of Rạch Gầm-Xoài Mút.

Conquest of Trịnh lords
Having vanquished the Nguyễn for the time being, Nguyễn Huệ decided to destroy the power of the Trịnh lords. He marched to the north at the head of a large army in 1786, and after a short campaign, defeated the Trịnh army successfully. The Trịnh were also unpopular and the Tây Sơn army seemed invincible. The Trịnh lord fled north into China. Nguyễn Huệ later married princess Lê Ngọc Hân, the daughter of the nominal later Lê Emperor, Lê Hiển Tông.

Defeat of Qing Empire 
A few months later, realising that his hope of retaining power had gone, the Emperor Lê Chiêu Thống fled north to the Qing Empire of China, where he formally petitioned the Qianlong Emperor for aid. The Qianlong Emperor agreed to restore Lê Chiêu Thống to power, and so in 1788, a large Qing army marched south into Vietnam and captured the capital Thăng Long.

Nguyễn Huệ gathered a new army and prepared to fight the Qing army. He addressed his troops before the battle saying:

In a surprise attack, while the Qing army was celebrating the Lunar New Year, Nguyễn Huệ's army defeated them at the Battle of Ngọc Hồi-Đống Đa and forced them, along with Lê Chiêu Thống, to flee back to China.

The Tay Son were supported by Chinese pirates. Anti-pirate activities were undertaken by a joint alliance between Qing China and Nguyễn lords Gia Long while Chinese pirates collaborated with the Tay Son.

Decline and fall 

After Emperor Quang Trung's death, his son Nguyễn Quang Toản was enthroned as Emperor Cảnh Thịnh at the age of ten. However, the real power was in the hands of his uncle Bui Dac Tuyen, who enacted a massive political purge. Many who served under Quang Trung were executed, while others became discouraged and left the regime, considerably weakening the Tây Sơn. This paved the way for Nguyễn Ánh to capture the entire country within 10 years, with the help of French military adventurers enlisted by French bishop Pigneau de Behaine. In 1800, Nguyễn Ánh occupied Quy Nhơn citadel. In 1801, he occupied Phú Xuân, forcing Nguyễn Quang Toản to flee to Thăng Long. In 1802, Anh besieged Thăng Long. The then 20-year-old Nguyễn Quang Toản escaped, but then was captured and executed, ending the dynasty after 24 years, and the Nguyễn, the last imperial dynasty of Vietnam, took over the country in 1802.

The Nguyễn used crushing by elephant to execute the defeated Tay Son leader Bùi Thị Xuân. The heart and liver from her body were consumed by soldiers of the Nguyễn.