Ancient history
The ancient history of Kathmandu is described in its traditional myths and legends. According to the scripture of Swayambhu Purana, present-day Kathmandu was once a huge and deep lake where dwelt mythical serpents (Nāgas) like Karkotaka, Takshaka and Kulika and the Buddhas, bodhisattvas, hermits, yogis, gods and goddesses as well as other celestial beings used to come for ablution in its water. Vipassī Buddha, who lived ninety-one kalpas (aeon) ago, came on a pilgrimage and sowed the seed of a lotus in the lake which grew into a lotus flower with thousand petals. The flower emitted eternal radiant form of light with the Five Great Buddhas, Vairocana, Akshobhya, Ratnasambhava, Amitābha and Amoghasiddhi appearing on each side of the differently coloured rays of the light. Following on the footsteps of Vipassī Buddha, Sikhī Buddha and Vessabhū Buddha came to pay homage to the lotus flower thirty-one kalpas ago. Later on, Bodhisattva Manjushri came to the lake and pondered how to drain the lake so that people can traverse and pay homage to the radiant light. Out of his compassion, he drained the lake out of the valley by cutting the mountain with his indestructible sword; and created other lakes nearby to give shelter to the mythical serpents. The self-arisen ray of light in a thousand - petaled lotus came to be worshipped as Swayambhu. Manjushri then established a city called Manjupattan, and made Dharmakar the ruler of the valley land. After some time, a demon named Banasura closed the outlet, and the valley again turned into a lake. Krishna came to Nepal, killed Banasura, and again drained out the water by cutting the edge of Chobhar hill with this Sudarshana Chakra. He brought some cowherds along with him, and made Bhuktaman the king of Nepal.
Kotirudra Samhita of Shiva Purana, Chapter 11, Shloka 18 refers to the place as Nayapala city, which was famous for its Pashupati Shivalinga. The name Nepal probably originates from this city Nayapala. Very few historical records exists of the period before medieval Licchavi rulers. According to Gopalraj Vansawali, a genealogy of Nepali monarchy, the rulers of Kathmandu Valley before the Licchavis were Gopalas, Mahispalas, Aabhirs, Kirat, and Somavanshi. The Kirata dynasty was established by Yalamber. During the Kirata era, a settlement called Yambu existed in the northern half of old Kathmandu. In Kiranti languages, Kathmandu is still referred to as Yambu (sometimes Yelakhom). Another smaller settlement called Yengal was present in the southern half of old Kathmandu, near Manjupattan. During the reign of the seventh Kirata ruler, Jitedasti, Buddhist monks entered Kathmandu valley and established a forest monastery at Sankhu.
The Licchavis from Vaisali in modern-day Bihar migrated north and defeated the Kirats, establishing the Licchavi dynasty circa 400 AD. During this era, following the genocide of Shakyas in Lumbini by Virudhaka, the survivors migrated north and entered the forest monastery, masquerading as Koliyas. From Sankhu, they migrated to Yambu and Yengal (Lanjagwal and Manjupattan) and established the first permanent Buddhist monasteries of Kathmandu. This created the basis of Newar Buddhism, which is the only surviving Sanskrit-based Buddhist tradition in the world. With their migration, Yambu was called Koligram and Yengal was called Dakshin Koligram during most of the Licchavi era.
Eventually, the Licchavi ruler Gunakamadeva merged Koligram and Dakshin Koligram, founding the city of Kathmandu. The city was designed in the shape of Chandrahrasa, the sword of Manjushri. The city was surrounded by eight barracks guarded by Ajimas. One of these barracks is still in use at Bhadrakali (in front of Singha Durbar). The city served as an important transit point in the trade between India and Tibet, leading to tremendous growth in architecture. Descriptions of buildings such as Managriha, Kailaskut Bhawan, and Bhadradiwas Bhawan have been found in the surviving journals of travellers and monks who lived during this era. For example, the famous 7th-century Chinese traveller Xuanzang described Kailaskut Bhawan, the palace of the Licchavi king Amshuverma.
The trade route also led to cultural exchange as well. The artistry of the Newar people—the indigenous inhabitants of the Kathmandu Valley—became highly sought after during this era, both within the Valley and throughout the greater Himalayas. Newar artists travelled extensively throughout Asia, creating religious art for their neighbours. For example, Araniko led a group of his compatriot artists through Tibet and China. Bhrikuti, the princess of Nepal who married Tibetan monarch Songtsän Gampo, was instrumental in introducing Buddhism to Tibet.
The Licchavi era was followed by the Malla era. Rulers from Tirhut, upon being attacked by the Delhi Sultanate, fled north to the Kathmandu valley. They intermarried with Nepali royalty, and this led to the Malla era. The early years of the Malla era were turbulent, with raids and attacks from Khas and Turk Muslims. There was also a devastating earthquake which claimed the lives of a third of Kathmandu's population, including the king Abhaya Malla. These disasters led to the destruction of most of the architecture of the Licchavi era (such as Mangriha and Kailashkut Bhawan), and the loss of literature collected in various monasteries within the city. Despite the initial hardships, Kathmandu rose to prominence again and, during most of the Malla era, dominated the trade between India and Tibet. Nepali currency became the standard currency in trans-Himalayan trade.
During the later part of the Malla era, Kathmandu Valley comprised four fortified cities: Kantipur, Lalitpur, Bhaktapur, and Kirtipur. These served as the capitals of the Malla confederation of Nepal. These states competed with each other in the arts, architecture, esthetics, and trade, resulting in tremendous development. The kings of this period directly influenced or involved themselves in the construction of public buildings, squares, and temples, as well as the development of waterspouts, the institutionalisation of trusts (called guthis), the codification of laws, the writing of dramas, and the performance of plays in city squares. Evidence of an influx of ideas from India, Tibet, China, Persia, and Europe among other places can be found in a stone inscription from the time of king Pratap Malla. Books have been found from this era that describe their tantric tradition (e.g. Tantrakhyan), medicine (e.g. Haramekhala), religion (e.g. Mooldevshashidev), law, morals, and history. Amarkosh, a Sanskrit-Nepal Bhasa dictionary from 1381, was also found. Architecturally notable buildings from this era include Kathmandu Durbar Square, Patan Durbar Square, Bhaktapur Durbar Square, the former durbar of Kirtipur, Nyatapola, Kumbheshwar, the Krishna temple, and others.