The Shah era of Nepal began with the Gorkha king Prithvi Narayan Shah invading Kathmandu valley, which consisted of the capital of the Malla confederacy. Until that time only the Kathmandu valley was referred to as Nepal. The confederacy requested help from the East India Company and an ill-equipped and ill-prepared expedition numbering 2,500 was led by Captain Kinlock in 1767. The expedition was a disaster; the Gorkhali army easily overpowered those who had not succumb to malaria or desperation . This ineffectual British force provided the Gorkhali with few firearms to arms themselves and make effective use of it.
Victory and occupation of the Kathmandu Valley by Prithvi Narayan Shah, starting with the Battle of Kirtipur, resulted in the shift of the capital of his kingdom from Gorkha to Kathmandu, and subsequently the empire that he and his descendants built came to be known as Nepal. Also, the invasion of the wealthy Kathmandu Valley provided the Gorkha army with economic support for furthering their martial ambitions throughout the region.
To the north however, aggressive raids into Tibet (concerning a long-standing dispute over trade and control of the mountain passes) triggered Chinese intervention. In 1792 the Qianlong Emperor sent an army, expelling the Nepalese from Tibet to within 5 kilometres (3.1 mi) of their capital at Kathmandu. Acting regent Bahadur Shah (Prithvi Naryan's younger son) appealed to the then British Governor-General of India for help. Anxious to avoid confrontation with the Chinese, the Governor-General did not send troops but sent Captain Kirkpatrick as mediator. However, before he arrived the war with China had finished. In 1789, Tibetan government stopped the usage of Nepalese coins for trade in Tibet, citing purity concerns over the copper and the silver coins minted by the Nepalese government, which led to the first
Nepal-Tibet war. A resounding victory of Gorkha forces over Tibetans in the first
Nepal-Tibet war left the Lhasa Durbar with no choice but to ask for assistance from the Qing Emperor in Peking. In the immediate aftermath of the Sino-Nepalese War (1789–1792), Nepal was forced to sign the 'Treaty of Betrawati' which stipulated that the Government of Nepal was required to make payment of tribute to Qing court in Peking once every five years, after the defeat of Gurkha forces by the Qing army in Tibet.
The Tibet affair had postponed a previously planned attack on the Garhwal Kingdom, but by 1803 the Raja of Garhwal, Pradyuman Shah, had also been defeated. He was killed in the struggle in January 1804 and all his land annexed. Further west, general Amar Singh Thapa overran lands as far as Kangra – the strongest fort in the hill region – and laid siege to it. However, Maharaja Ranjit Singh, the ruler of the Sikh state in Punjab, intervened and drove the Nepalese army east of the Sutlej river by 1809.