During that time, however, a ruler of the tiny hilltop kingdom of Gorkha, King Prithvi Narayan Shah, was setting out on his quest to unify the country, and in A.D. 1768, he took over Kathmandu, and then, Kirtipur, one year later. He set up his capital in Kathmandu, and thus began the dynasty of the Shah rulers, who reigned for almost 240 years over the country now known as Nepal. In the initial stages, within six years of taking over Kathmandu Valley, Prithvi Narayan Shah’s victorious Gorkha army conquered eastern Nepal, as well as the adjoining state of Sikkim. Next, it turned its attention westwards into Kumaon and Garhwal in India, where a one-eyed Punjabi king named Ranjit Singh just about managed to stop them at the Punjab border.
It was a heady time for the new kingdom, with its army winning one battle after the other, and with new territory being added with every victory. But, in 1792, an excursion into Tibet was not so successful, a bit too much adventure for the valiant Gorkha army to swallow, and they suffered defeat at the hands of a large Chinese army, which then advanced to within 35 km of Kathmandu, advancing down from the Kerung Valley. Leaving this unfortunate episode aside, Nepal had expanded considerably by now, its borders stretching from Kashmir to Sikkim.
Of course, as with everything else, all good things had to come to an end, and the Gorkha’s exploits eventually brought them face-to-face with the all-powerful British Raj in India, resulting in the first Anglo-Nepali war that carried on for two-years, with the British finally emerging victorious. However, the amazing fighting spirit of the Gorkha’s was admirable, and so, the British began to recruit Gorkhas into their own army. At the same time, they also came up with the Sugauli Treaty of 1816 that halted Nepal’s expansionist ambitions, and drew its modern boundaries. This meant giving up Sikkim, Kumaon, Garhwal, and a substantial part of the Terai. In 1858, to show their appreciation of Nepal’s support in putting down the Indian Mutiny, some of this land was restored.
In between all this, King Prithvi Narayan Shah died in 1775, and his death led to intrigue-riddled succession struggles, which culminated in the Kot Massacre of 1846 that was engineered by Jung Bahadur, a young nobleman of the Chhetri clan. He, with the queen's consent, arranged for the massacre by his soldiers of hundreds of noblemen, soldiers, and courtiers who were made to assemble, under some pretext, in the Kot courtyard near Kathmandu Durbar Square. Next, Jang Bahadur exiled thousands of the murdered victims’ families to ensure that there were no revenge attacks. The result was that the Shah dynasty was pushed into the sidelines, with Jung Bahadur’s dynasty becoming all powerful. Changing his family name to the more prestigious one of Rana, he claimed for himself the designation of Prime Minister, and later, entitled himself maharajah, a title that would henceforth be hereditary. Thus, the Ranas became another ‘royal family' within the kingdom, keeping a firm hold on the rein of power, and this they continued to do for another 100 years. The Shah kings became mere figureheads.
Finally, in late 1950, King Tribhuvan Bir Bikram Shah took refuge in the Indian embassy, and was flown to India. At the same time, a political party called Nepali Congress led by a man called B.P. Koirala succeeded in forcibly taking control of most parts of the Terai, where they established a provisional government with its capital in Birgunj. In 1951, the king returned to Nepal and established a new government made up of Nepali Congress party members and some demoted Ranas. In 1955, the king died, and was succeeded by his son, Mahendra. In 1959, the country held its first general election, as per the provisions of the new constitution that provided for a parliamentary system. The Nepali Congress, expectedly, won, and B.P. Koirala became the new prime minister. It was a short-lived reign, however, because in late 1960, the king took over complete control, and had the cabinet thrown into jail. He then established a party-less Panchayat (council) system in 1962, and banned political parties.