Much of Nepal's early history is known only by legend. Apparently there were migrations from surrounding areas, and small tribal principalities were established. It is thought that by the seventh century the Newar tribes controlled Nepal, which then consisted solely of the Kathmandu Valley. The region came under Tibetan domination for a time. In the 11th century control passed to India. In the late 18th century a ruler of Gurkha (a country west of Kathmandu) seized control of the Kathmandu Valley and most of the area that is now Nepal.

The Gurkhas established friendly relations with the British in India, but in 1814 the two groups went to war as a result of border disputes. A peace treaty in 1816 granted Great Britain territorial concessions. The Ranas, a family of court officials, seized power in the 1840's and established themselves as hereditary prime ministers, reducing the king to a figurehead. Following a successful invasion of Tibet in 1854, Nepal gained territory and forced Tibet to send an annual tribute (which continued until stopped by the Chinese in 1953).

A popular revolution in 1950–51 overthrew the Rana prime minister and restored all power to the king. In 1959 King Mahendra issued a constitution, and the country's first parliamentary government was elected. However, the king assumed authoritarian rule in 1960 and issued a constitution in 1962 lacking democratic provisions. In 1975 King Mahendra died, and his son Birenda Bir Bikram Shav Dev succeeded to the throne.

Beginning in the 1970's, conflict between the king and supporters of democracy disrupted the country. In 1980, after severe rioting by supporters of democracy, the king agreed to amend the constitution and permit the election of a legislature. He did not allow the formation of political parties, however. In 1990 the king legalized political parties and later consented to the adoption of a democratic constitution. Democratic elections were held in 1991.

Beginning in 1996, Maoist rebels began fighting for a Communist government instead of the constitutional monarchy then in power. For ten years, the rebellion hurt and intimidated the Nepalese.

In 2001, ten members of the royal family were shot to death, including the king, queen, and crown prince, who was identified as the person who committed the murders. The king's brother Gyanendra then ascended the throne.

In October, 2002, King Gyanendra dismissed Prime Minister Sher Bahadur Deuba and installed his own replacement as well as a new cabinet to run the country.

In mid-2004, King Gyanendra reassigned Deuba to the prime minister post. But in February, 2005, the king again dismissed Deuba. At that time, the king assumed absolute power of Nepal. After a number of protests, Gyanendra was forced to relinquish power and appointed Girija Prasad Koirala as prime minister in April, 2006.

In November, 2006, the Communist rebels signed a peace deal with the government. The rebels joined an interim government the following year.