Bhaktapur’s historical roots lie in its position on the early trade route to Tibet (silk route), though the credit for the formal founding of the city goes to King Ananda Malla in the 12th century.
From the 14th to the 16th century, as Bhaktapur became the most powerful of the valley’s three Malla kingdoms, the focus of the town shifted west to the Durbar Square area. Much of the town’s great architecture dates from the rule of King Yaksha Malla (1428-82), who built the Pashupatinath(Yakcheswor Mahadev) and Dattatreya temples, but also from the end of the 17th century, during King Bhupatindra Malla’s reign. At its peak the city boasted 172 temples and monasteries, 77 water tanks, 172 pilgrim shelters and 152 wells.
The 15th-century royal palace in Durbar Square remained the seat of power until the city’s defeat by king Prithvi Narayan Shah in 1768 relegated the former capital to a market town.