Medieval history of Nepal

In the 11th century, a powerful empire of Khas people emerged in western Nepal whose territory at its highest peak included much of western Nepal as well as parts of western Tibet and Uttarakhand of India. By the 14th century, the empire had splintered into loosely associated Baise rajyas, literally 22 states as they were counted. The rich culture and language of the Khas people spread throughout Nepal and as far as Indo-China in the intervening centuries; their language, later renamed the Nepali language, became the lingua franca of Nepal as well as much of North-east India. In south-eastern Nepal, Simraungarh annexed Mithila around 1100 AD, and the unified Tirhut stood as a powerful kingdom for more than 200 years, even ruling over Kathmandu for a time. After another 300 years of Muslim rule, Tirhut came under the control of the Sens of Makawanpur. In the eastern hills, a confederation of Kirat principalities ruled the area between Kathmandu and Bengal.

In the Kathmandu valley, the Mallas had established themselves in Kathmandu and Patan by the middle of the 14th century. The Mallas ruled the valley first under the suzerainty of Tirhut but established independent reign by late 14th century as Tirhut went into decline. In the late 14th century, Jayasthiti Malla introduced widespread socio-economic reforms, principal of which was the caste system. By dividing the indigenous non-Aryan Buddhist population into castes modelled after the four Varna system of Hinduism, he provided an influential model for the Sanskritization and Hinduization of the indigenous non-Hindu tribal populations in all principalities throughout Nepal. By the middle of the 15th century, Kathmandu had become a powerful empire which, according to Kirkpatrick, extended from Digarchi or Sigatse in Tibet to Tirhut and Gaya in India. In the late 15th century, Malla princes divided their kingdom in four – Kathmandu, Patan and Bhaktapur in the valley and Banepa to the east. The competition for prestige among these brotherly kingdoms saw the flourishing of art and architecture in central Nepal, and the building of famous Kathmandu, Patan and Bhaktapur Durbar Squares; their division and mistrust led to their fall in the late 18th century, and ultimately, the unification of Nepal into a modern state.

Apart from one destructive sacking of Kathmandu in the early 13th century, Nepal remained largely untouched by the Muslim invasion of India that began in the 11th century. However, the Mughal period saw an influx of high-caste Hindus from India into Nepal. They soon intermingled with the Khas people and by the 16th century, there were about 50 Rajput-ruled principalities in Nepal, including the 22 (Baisi) states in western Nepal and, to their east in west-central Nepal, 24 Chaubisi states.

Thakuri dynasty
The Thakuri dynasty were Rajputs. After Aramudi, who is mentioned in the Kashmirian chronicle, the Rajatarangini of Kalhana (1150 CE), many Thakuri kings ruled over parts of the country up to the middle of the 12th century CE. Raghava Deva is said to have founded a ruling dynasty in 879 CE, when the Lichhavi rule came to an end. To commemorate this important event, Raghava Deva started the 'Nepal Era' which began on 20 October, 879 CE. After Amshuvarma, who ruled from 605 CE onward; the Thakuris had lost power and they could regain it only in 869 CE.

Gunakama Deva, who ruled from 949 to 994 CE, commissioned the construction of a big wooden shelter, built from the wood of a single tree, called Kasthamandapa. The name of the capital, 'Kathmandu', is derived from this. Gunakama Deva founded the town Kantipur (modern-day Kathmandu). The tradition of Indra Jatra started during his reign. Bhola Deva succeeded Gunakama Deva. The next ruler was Laxmikama Deva who ruled from 1024 to 1040 CE. He built the Laksmi Vihara and introduced the tradition of worshiping the Kumari; young prepubescent girls believed to be manifestations of the divine female energy or devi. He was succeeded by his son, Vijayakama Deva, who introduced the worship of the Naga and Vasuki. Vijaykama Deva was the last ruler of this dynasty. After his death, the Thakuri clan of Nuwakot occupied the throne of Nepal.

Bhaskara Deva, a Thakuri from Nuwakot, succeeded Vijayakama. He is said to have built Navabahal and Hemavarna Vihara. After Bhaskara Deva, four kings of this line ruled over the country. They were Bala Deva, Padma Deva, Nagarjuna Deva and Shankara Deva. Shankara Deva (1067–1080 CE) was the most illustrious ruler of this dynasty. He established the image of 'Shantesvara Mahadeva' and 'Manohara Bhagavati'. The custom of pasting the pictures of Nagas and Vasuki on the doors of houses on the day of Nagapanchami was introduced by him. During his rule, the Buddhists wreaked vengeance on the Hindu Brahmins (especially the followers of Shaivism) for the harm they had received earlier from the Shankaracharya. Shankara Deva tried to pacify the Brahmins harassed by the Buddhists.

Bama Deva, a descendant of Amshuvarma, defeated Shankar Deva in 1080 CE. He suppressed the Nuwakot-Thankuris with the help of nobles and restored the old Solar Dynasty rule in Nepal for the second time. Harsha Deva, the successor of Bama Deva was a weak ruler. There was no unity among the nobles and they asserted themselves in their respective spheres of influence. Taking that opportunity Nanya Deva, a Karnat dynasty king, attacked Nuwakot from Simraungarh. The army successfully defended and won the battle. After Harsha Deva, Shivadeva the third ruled from 1099 to 1126 CE. He founded the town of Kirtipur and roofed the temple of Pashupatinath with gold. He introduced twenty-five paisa coins. After Sivadeva III, Mahendra Deva, Mana Deva, Narendra Deva II, Ananda Deva, Rudra Deva, Amrita Deva, Ratna Deva II, Somesvara Deva, Gunakama Deva II, Lakmikama Deva III and Vijayakama Deva II ruled Nepal in quick succession. Historians differ about the rule of several kings and their respective times. After the fall of the Thakuri dynasty, a new dynasty was founded by Arideva or Ari Malla, known as the 'Malla dynasty'.

Malla dynasty
Early Malla rule started with Ari Malla in the 12th century. Over the next two centuries, his kingdom expanded widely, into much of the Indian subcontinent and western Tibet, before disintegrating into small principalities, which later came to be known as the Baise Rajya.

Jayasthiti Malla, with whom commences the later Malla dynasty of the Kathmandu valley, began to reign at the end of the 18th century. Malla dynasty was the longest ruling dynasty in Nepalese history, ruling from the 12th century to the 18th century (about 600 years). This era in the valley is eminent for the various social and economic reforms such as the 'Sanskritization' of the valley people, new methods of land measurement and allocation, etc. In this era, new forms of art and architecture was introduced. The monuments in Kathmandu valley which are listed in the UNESCO World Heritage Sites were built during Malla rule. In the 14th century, before Kathmandu was divided into 3 princely states, Araniko was sent to China upon the request of Abhaya Malla for representing the skill of art and architecture, and he introduced the Pagoda style of architecture to China and subsequently, whole of Asia. Yaksha Malla, the grandson of Jayasthiti Malla, ruled the Kathmandu valley until almost the end of the 15th century. After his demise, the valley was divided into three independent kingdoms—Kathmandu, Bhaktapur, and Patan—in about 1484 CE. This division led the Malla rulers into internecine clashes and wars for territorial and commercial gains. Mutually debilitating wars gradually weakened them, which facilitated the conquest of the valley by Prithvi Narayan Shah of Gorkha. The last Malla rulers were Jaya Prakash Malla, Teja Narasingha Malla and Ranjit Malla of Kathmandu, Patan, and Bhaktapur respectively.

Simroun dynasty
The Simroun, Simroon, Karnat or Dev dynasty originated with an establishment of a kingdom in 1097 CE headquartered at present-day Simroungarh in Bara district. The kingdom controlled the areas today known as Tirhoot or Mithila in Nepal and Bihar of India. The rulers of Simroungarh were as follows: In 1324 CE, Ghiyasuddin Tughlaq attacked Simroungarh and demolished the fort. The remains are still scattered across the Simroungarh region. The king, Harisingh Dev, fled northwards where his son, Jagatsingh Dev, was married to the widowed princess of Bhaktapur, Nayak Devi.
 * Nanya Dev, ruled 1097-1147 CE
 * Ganga Dev, ruled 1147-1187 CE
 * Narsingh Dev, ruled 1187-1227 CE
 * Ramsingh Dev, ruled 1227-1285 CE
 * Shaktisingh Dev, ruled 1285-1295 CE
 * Harisingh Dev, ruled 1295-1324 CE

Shah dynasty, Unification of Nepal
Prithvi Narayan Shah (c. 1768–1775) was the ninth generation descendant of Dravya Shah (1559–1570), the founder of the ruling house of Gorkha. Prithvi Narayan Shah succeeded his father Nara Bhupal Shah to the throne of Gorkha in 1743 CE. King Prithvi Narayan Shah was quite aware of the political situation of the valley kingdoms as well as of the Baise and Chaubise principalities. He foresaw the need for unifying the small principalities as an urgent condition for survival in the future and set himself to the task accordingly.

His assessment of the situation among the hill principalities was correct, and the principalities were subjugated fairly easily. King Prithvi Narayan Shah's victory march began with the conquest of Nuwakot, which lies between Kathmandu and Gorkha, in 1744. After Nuwakot, he occupied strategic points in the hills surrounding the Kathmandu valley. The valley's communications with the outside world were thus cut off. The occupation of the Kuti Pass in about 1756 stopped the valley's trade with Tibet. Finally, Prithvi Narayan Shah entered the valley. After the victory in Kirtipur, King Jaya Prakash Malla of Kathmandu sought help from the British and the then East India Company sent a contingent of soldiers under Captain Kinloch in 1767. The British force was defeated in Sindhuli by the Gorkhali army. This defeat of the British completely shattered the hopes of King Jaya Prakash Malla. On 25 September 1768, as the people of Kathmandu were celebrating the festival of Indra Jatra, the Gorkhali army marched into the city. Prithvi Narayan Shah sat on a throne put on the palace courtyard for the king of Kathmandu, proclaiming himself the king. Jaya Prakash Malla somehow managed to escape and took asylum in Patan. When Patan was captured a few weeks later, both Jaya Prakash Malla and Tej Narsingh Malla, the king of Patan took refuge in Bhaktapur, which was captured on the night of 25 November 1769. The Kathmandu valley was thus conquered by King Prithvi Narayan Shah, who proclaimed himself King with Kathmandu as the royal capital of the Kingdom of Nepal.

King Prithvi Narayan Shah was successful in bringing together diverse religio-ethnic groups under one rule. He was a true nationalist in his outlook and was in favor of adopting a closed-door policy with regards to the British. Not only his social and economic views guided the country's socio-economic course for a long time, his use of the imagery, 'a yam between two boulders' in Nepal's geopolitical context, formed the principal guideline of the country's foreign policy for future centuries.