For three centuries the Chaubisi and Baaisi confederacies were able to maintain an uneasy status quo, forming numerous defensive alliances to ensure that no one state could gain control over the rest. Divided, they were small, weak and culturally backward.
Gorkha
, the most easterly territory, was no different from the rest, except that it was that much closer to the Kathmandu Valley and that much more jealous of the Mallas' wealth. Under the inspired, obsessive leadership of
Prithvi Narayan Shah
(1722-75), Gorkha launched a campaign that was to take 27 years to conquer the valley, and as long again to unite all of modern Nepal.
At the time of Prithvi Narayan's rise to the throne, in 1743, rivalry between the three Malla kings had reached an all-time high. Still, Gorkha wasn't nearly strong enough to invade Nepal outright; Prithvi Narayan first captured Nuwakot, a day's march northwest of Kathmandu, and from there directed a ruthless twenty-year
war of attrition
. By 1764 he was able to enforce a total blockade, starving the valley and at the same time replenishing Gorkha's coffers with Tibetan trade. Kirtipur was targeted for the first major battle, and surrendered after a six-month siege. Answering a plea from the Kathmandu king, Jaya Prakash Malla, the East India Company sent in 2400 soldiers against the Gorkhalis, who proceeded to cut them to shreds; only 800 returned. On the eve of Indra Jaatra in 1768, Jaya Prakash, by now rumoured to be insane, let down the city's defences and
Kathmandu fell
to the Gorkhalis without a fight. They took Patan two days later, and Bhaktapur the following year, and by 1774 had marched eastwards all the way to Sikkim.
Suspicious of Britain's growing influence in India, Prithvi Narayan adopted a closed-door policy that was to remain in force until the 1950s. Missionaries were thrown out forthwith: "First the Bible, then the trading station, then the cannon," he warned. The bloody
battle for succession
that followed Prithvi Narayan's death set the pattern for Nepali politics well into the twentieth century. Yet when they weren't stabbing each other in the back, his successors managed to subdue Gorkha's old Chaubisi and Baaisi rivals in the west, so that by 1790 Nepal stretched far beyond its present eastern and western borders. Lured on by promises of land grants - every hillman's dream - the Nepali army became a seemingly unstoppable fighting machine, with Kashmir in its sights.
Westward progress was interrupted, however, by a brief but chastening
war with Tibet
. Troubles had been brewing for some time over trade relations, and the Tibetans were growing alarmed by Nepal's encroachments on their ally, Sikkim. In 1788 and again in 1791, Nepal invaded, plundered a few monasteries and exacted tribute from Tibet, but in 1792 the Tibetans launched a counterattack, penetrating as far as Nuwakot and forcing Nepal to accept harsh terms.
Nepal's further adventures in the west brought it into increasing
conflict with Britain
's East India Company, which by now controlled India, and open hostilities broke out in 1814 when Nepal annexed the Butwal sector of the Tarai. For the British, the dispute provided a perfect pretext to "open up" Nepal, which had been so tantalizingly closed to them, and thus to muscle in on trade with Tibet. Britain attacked with a force of 50,000 men against Nepal's 12,000, expecting an easy victory; in the event it took two years and heavy losses before Nepal was finally brought to heel. The
Treaty of Segauli
forced Nepal to accept its present eastern and western boundaries and surrender much of the Tarai, and worst of all, to admit an official British "resident" in Kathmandu. Yet so impressed were the British by "our valiant opponent" - as a plaque at an Indian battle site still proclaims - that they began recruiting Nepalis into the Indian Army before the treaty had even been signed. These companies formed the basis for the famed
Gurkha regiments
. Britain restored Nepal's Tarai lands in return for its help in quelling the Indian Mutiny of 1857.