Unification of Nepal
The unification of Nepal () was the process of building the modern Nepalese state, from fractured petty kingdoms including the Baise Rajya (22 Kingdoms) and the Chaubisi Rajya (24 Kingdoms), which began in 1743 AD (1799 BS). The prominent figure in the unification campaign was Prithvi Narayan Shah, King of Gorkha. On 25 September 1768, he officially announced the creation of the Kingdom of Nepal and moved his capital from Gorkha to the city of Kathmandu. The Shah dynasty would go on to expand the various warring kingdoms that once occupied parts of present-day Nepal into a nation-state that stretched up to the Sutlej River in the west and Sikkim-Jalpaiguri in the east. Before the Gorkha Empire, the Kathmandu Valley was known as Nepal after the Nepal Mandala, the region's name in Nepal Bhasa. Background 
The regions that constitute present-day Nepal were scattered as numerous independent kingdoms prior to unification. The Kathmandu Valley, then called Nepal Mandala, alone contained three independent kingdoms: Kantipur, Lalitpur, and Bhadgaon. Makwanpur, to the south of the valley, was ruled by the Sen dynasty. To the east of the valley were two relatively larger kingdoms: Vijayapur, and Chaudandi. Both of these kingdoms once belonged to Makawanpur, but Mukunda Sena () had partitioned his kingdom among his sons and relatives and had divided the once large Makawanpur into various principalities. Between the rivers Trishuli and Bheri, known as the Gandaki region, were the Chaubisi principalities. Further west, in the Karnali region, were the Baise principalities. Baise and Chaubise literally translate to twenty-two and twenty-four kingdoms respectively, but the exact number of kingdoms wasn't the same as the regions' collective names. The Baises were once a part of the Khasa Kingdom, ruled by the Khas Mallas from the Sinja valley, before its fragmentation. The Chaubisi principalities belonged to various political entities. Some belonged to the Senas, some to the Khas Mallas, and some to the Shahis. These principalities experienced constant change and instability. Several kingdoms made leagues in order to protect themselves from foreign invasions and for mutual growth. However, due to the economic and geographic conditions prevalent at that time, disputes and battles between the kingdoms were frequent. The Malla kings of the valley engaged in incessant conflicts and skirmishes among themselves and had, at several instances, requested the intervention of Gorkha to settle their disputes. Battle campaigns

Nuwakot 

Prithvi Narayan Shah's annexation campaign began with the nearby kingdom of Nuwakot. Nuwakot marked the eastern boundary of the Gorkha Kingdom and was part of the trade route between Tibet and Kathmandu. It was also the western gateway to the Kathmandu Valley. Nara Bhupal Shah, Prithvi Narayan Shah's father, had attempted to invade Nuwakot in 1700, but failed. At that time, Nuwakot was under the administrative control of Kantipur (known today as Kathmandu). Kantipur supported Nuwakot against the invasion. Following his defeat, Nara Bhupal Shah gave up his efforts and handed administrative power over to his eldest son, Prithvi Narayan Shah and Chandraprabhawati, his eldest queen. In the very year of his coronation, Prithvi Narayan Shah sent Gorkhali troops under Kaji Biraj Thapa Magar to attack Nuwakot. The campaign failed. Kalu Pande was then made Commander-in-Chief of the Gorkhali Army. Kalu Pande advised Prithvi Narayan Shah to raise a standing army by conscripting men from other regions. A newly fortified Gorkhali force again attacked Nuwakot in 1744 from three sides and managed to capture the hill fort on September 26, 1744. However, the next year, King Jaya Prakash Malla of Kantipur sent a force under Kashiram Thapa to retake the fort, after defeating the Gorkhali forces at Naldum. Kashiram was repelled and the Gorkhali seized permanent control of Nuwakot. Tanahun 
While Prithvi Narayan Shah was occupied with Nuwakot, Tanahun, a small kingdom to the west, took advantage of the king's absence to invade the Gorkha kingdom. Tanahun troops crossed the Chepe river and captured Sirhanchowk. But reinforcements from both Nuwakot and Gorkha managed to rout the invaders and considerably weaken Lamjung. Prithvi Narayan Shah wanted to use the occasion to invade Tanahun and annex it. However, he was advised against an open attack as King Tribikram Sen of Tanahun was an old friend of his father's. Prithvi Narayan Shah thus invited Tribikram Sen to the banks of the Trishuli river on the pretext of a friendly visit and then took him into custody. Tribikram Sen was imprisoned in Nuwakot and Tanahun was officially annexed to the burgeoning Gorkha Empire. Makwanpur and Hariharpur 

As part of his goal of taking the Kathmandu Valley, Prithvi Narayan had planned to first conquer all of the kingdoms and principalities surrounding the Kathmandu Valley. Sensing danger, King Digbardhan Sen and his minister Kanak Singh Baniya of Makwanpur sent their families to safer grounds before they were encircled by the Gorkhalis, who launched an attack on 17 August 1762. The battle lasted for around eight hours and while Makwanpur was annexed, King Digbardhan and Kanak Singh escaped to Hariharpur Gadhi. After occupying the Makwanpur, the Gorkhali forces planned to take Hariharpur Gadhi, a strategic fort on a mountain ridge of the Mahabharat range, also south of Kathmandu. It controlled another route to the Kathmandu valley. On 4 October 1762, the Gorkhalis launched Hariharpur. The soldiers there fought valiantly against the Gorkha forces, but were ultimately forced to vacate the fort. About 500 soldiers from Hariharpur died in the battle. Digbardhan Sen sought the help of Mir Qasim, the Nawab of Bengal, to help defend against the Gorkhalis. Mir Qasim, sought to gain loot and plunder from the invasion, as he was using lavish gifts to get on the East India Company's good side. In December 1762, he sent around 3,500 troops under Gurgin Khan, an Armenian man named Gregory who had helped train Mir Qasim's army, to launch an attack on Makwanpur, which had only recently been captured by the Gorkhalis. Mir Qasim's forces arrived in Makwanpur in January 1763 and launched an attack on Dadhuwa Gadhi, one of three defensive positions the Gorkhalis had set up around Makwanpur fort. Gurgin Khan's 3,500 soldiers managed to capture Dadhuwa Gadhi from 400 or so Gorkha soldiers. On 21 January 1763, 3,300 of Gurgin Khan's soldiers launched an attack on Makwanpur palace. The Gorkhalis, under Prithvi Narayan's brother Nandu Shah, held off the invaders. Supplemented by reinforcements, the Gorkhalis counter-attacked Gurgin Khan in the dead of the night while his soldiers were asleep. The Gorkhalis managed to rout Gurgin Khan's forces, who retreated back to Bengal. Kathmandu Valley (Nepal Mandala) 

The Shah kings had long set their sights on the Nepal Valley, now also known as Kathmandu Valley, which was host to three wealthy but constantly warring city-states ruled by the Malla dynasty. After conquering Nuwakot, which was the western gateway to the Kathmandu Valley, the Gokhalis aimed for Kirtipur as their next target. Kirtipur was a small fortified city on the outskirts of the three major city-states ruled by Newar Malla kings. Despite his initial assessment that the valley kings were well prepared and the Gorkhalis were not, Kalu Pande agreed to lead the battle. In 1757, The Gorkhalis set up a base on Naikap to mount their assault on Kirtipur. They were armed with swords, bows and muskets. The two forces fought on the plain of Tyangla Phant in the northwest of Kirtipur. Kalu Pande was killed in the battle while Prithvi Narayan himself narrowly escaped with his life into the surrounding hills disguised as a saint. In 1764, Prithvi Narayan assaulted Kirtipur a second time. The attacking forces were under the command of Surapratap Shah, Prithvi Narayan's brother. The Gorkhalis were defeated once again and Surapratap lost his right eye to an arrow while scaling the city. A noble of Lalitpur named Danuvanta crossed over to Shah's side and let the Gorkhalis into the town. The victory in the Battle of Kirtipur made Shah's two-decade-long effort to take possession of the Kathmandu Valley possible. After the fall of Kirtipur, Shah took the city-state of  Kathmandu in 1768. That same year he also took possession of  Lalitpur. In 1769 he took possession of Bhaktapur, completing his conquest of the Nepal Valley. In a letter to Ram Krishna Kunwar, King Prithvi Narayan Shah was unhappy at the death of Kaji Kalu Pande in Kirtipur and thought it was impossible to conquer Kathmandu valley after the death of Kalu Pande. After the annexation of Kathmandu Valley, King Prithvi Narayan Shah praised in his letter about the valour and wisdom shown by Ramkrishna in the annexation of Kathmandu, Lalitpur and Bhaktapur (i.e. the Nepal valley at the time) in 1768-69 A.D. Similarly,  Vamsharaj Pande, Kalu Pande's eldest son, was the army commander who led attack of Gorkhali side on the Battle of Bhaktapur on 14 April 1769 A.D.

After his conquest of the Kathmandu Valley, Prithvi Narayan Shah conquered other smaller territories south of the valley to keep other smaller fiefdoms near his Gurkha state out of British rule. After his kingdom spread from north to south, he made Kantipur the capital of the expanded country, which was then known as the Kingdom of Gorkha (Gorkha Samrajya). Sen Kingdom 

King Prithvi Narayan Shah had deployed Sardar Ram Krishna Kunwar to the invasion of Kirant regional areas comprising; Pallo Kirant (Limbuwan), Wallo Kirant and Majh Kirant (Khambuwan). On 29 August 1772, Ram Krishna crossed the Dudhkoshi river to invade the lands of King Karna Sen of Kirant and the Saptari region with fellow commander Abhiman Singh Basnyat. He crossed the Arun River to reach Chainpur. Later, he achieved victory over the rulers of the Kirant region. King Prithvi Narayan Shah bestowed 22 pairs of Shirpau (special headgear) on Ram Krishna Kunwar in appreciation of his victory over the rulers of the Kirant region. Post death of Prithvi Narayan Shah
In 1775 A.D., the conqueror king Prithvi Narayan Shah, who expanded the Gorkha Kingdom into the Kingdom of Nepal died at Devighat, Nuwakot. Swarup Singh Karki, a shrewd Gorkhali courtier from a Chhetri family of Eastern Nepal, marched with an army to Nuwakot to confine Prince Bahadur Shah of Nepal who was then mourning the death of his father former King Prithvi Narayan Shah. He confined Bahadur Shah and Prince Dal Mardan Shah with consent from newly reigning King Pratap Singh Shah who was considered to have no distinction of right and wrong. In the annual Pajani (renewal) of that year, Swarup Singh was promoted to the position of Kaji along with Abhiman Singh Basnyat, Amar Singh Thapa and Parashuram Thapa. In Falgun 1832 B.S., he succeeded in exiling Bahadur Shah, Dal Mardan Shah and Guru Gajraj Mishra on three heinous charges. The reign of King Pratap Singh was characterized by the constant rivalry between Swarup and Vamsharaj Pande, a member of the leading Pande family of Gorkha. The document dated Bikram Samvat 1833 Bhadra Vadi 3 Roj 6 (i.e. Friday 2 August 1776), shows that he had carried the title of Dewan along with Vamsharaj Pande. King Pratap Singh Shah died on 22 November 1777 A.D. leaving his infant son Rana Bahadur Shah as the King of Nepal. Sarbajit Rana Magar was made a Kaji along with Balbhadra Shah and Vamsharaj Pande while Daljit Shah was chosen as Chief Chautariya. Historian Dilli Raman Regmi asserts that Sarbajit was chosen as  Chief Kazi (equivalent to Prime Minister of Nepal). Historian Rishikesh Shah asserts that Sarbajit was the head of the Nepalese government for a short period in 1778. Afterwards, rivalry arose between Prince Bahadur Shah of Nepal and Queen Rajendra Laxmi. In the rivalry, Sarbajit led the followers of the Queen opposed to Sriharsh Pant who led the followers of Bahadur Shah. The group of Bharadars (officers) led by Sarbajit poisoned the ears of Rajendra Laxmi against Bahadur Shah. Rajendra Laxmi succeeded in the confinement of Prince Bahadur Shah with the help of her new minister Sarbajit. Guru Gajraj Mishra came to rescue Bahadur Shah on the condition that Bahadur Shah should leave the country. Also, his rival Sriharsh Pant was branded outcast and expelled instead of execution which was prohibited for Brahmins. Prince Bahadur Shah confined his sister-in-law Queen Rajendra Laxmi on the charge of having illicit relation with Sarbajit on 31 August 1778. Subsequently, Sarbajit was executed inside the palace by Prince Bahadur Shah with the help of male servants of the royal palace. Historian Bhadra Ratna Bajracharya asserts that it was actually Chautariya Daljit Shah who led the opposing group against Sarbajit Rana and Rajendra Laxmi. The letter dated B.S. 1835 Bhadra Sudi 11 Roj 4 (1778 A.D.) to Narayan Malla and Vrajabasi Pande asserts the death of Sarbajit under misconduct and the appointment of Bahadur Shah as regent. The death of Sarbajit Rana Magar is considered to have marked the initiation of court conspiracies and massacres in the newly unified Kingdom of Nepal. Historian Baburam Acharya points that the sanctions against Queen Rajendra Laxmi under moral misconduct was a mistake of Bahadur Shah. Similarly, the murder of Sarbajit was condemned by many historians as an act of injustice. Vamsharaj Pande, once Dewan of Nepal and son of the popular commander Kalu Pande, was beheaded on the conspiracy of Queen Rajendra Laxmi with his support. In the special tribunal meeting at Bhandarkhal garden, east of Kathmandu Durbar, Swaroop Singh held Vamsharaj liable for letting the King of Parbat, Kirtibam Malla to run away in the battle a year ago. He had a fiery conversation with Vamsharaj before Vamsharaj was declared guilty and was subsequently executed by beheading on the tribunal. Historian Rishikesh Shah and Ganga Karmacharya claim that he was executed in March 1785. Bhadra Ratna Bajracharya and Tulsi Ram Vaidya claim that he was executed on 21 April 1785. On 2 July 1785, his stiff opponent Prince Regent Bahadur Shah of Nepal was arrested and on the eleventh day of imprisonment on 13 July, his only supporter Queen Rajendra Laxmi died. Then onwards, Bahadur Shah took over the regency of his nephew King Rana Bahadur Shah and on the first moments of his regency ordered Swaroop Singh who was in Pokhara to be beheaded there  on the charges of treason. He had gone to Kaski to join Daljit Shah's military campaign of Kaski fearing retaliation of the old courtiers due to his conspiracy against Vamsharaj. He was executed on 24th Shrawan 1842 B.S. Tibetan conflict

After the death of Prithvi Narayan Shah, the Shah dynasty began to expand their kingdom into what is present day North India. Between 1788 and 1791, Nepal invaded Tibet and robbed the Tashi Lhunpo Monastery in Shigatse. Tibet sought help from the Chinese imperial court and the Qianlong Emperor of the Chinese Qing dynasty appointed Fuk'anggan commander-in-chief of the Tibetan campaign. Heavy damages were inflicted on both sides. The Nepali forces retreated step by step back to Nuwakot to stretch Sino-Tibetan forces uncomfortably. The Chinese launched uphill attack during the daylight and failed to succeed due to strong counterattack with Khukuri at Nuwakot. The Chinese army suffered a major setback when they tried to cross a monsoon-flooded Betrawati, close to the Gorkhali palace in Nuwakot. A stalemate ensued when Fuk'anggan was keen to protect his troops and wanted to negotiate at Nuwakot. The treaty was more favorable to the Chinese side and prescribed that Nepal had to pay tributes to the Chinese emperor. Timeline of unification
The timeline of unification is given in the following table. 