The city's history dates back to around 890 CE, as found in a stone inscription found at the Nageshwara Temple in Begur, Bangalore . In 1537 CE, Kempé Gowdā , a feudal ruler under the Vijayanagara Empire , established a mud fort , considered the foundation of modern Bangalore and its oldest areas, or pétés , which still exist. After the fall of the Vijayanagara Empire, Kempe Gowda declared independence; in 1638, a large Adil Shahi Bijapur army defeated Kempe Gowda III, and Bangalore was came under Shahaji Bhonsle as a jagir which later became his capital. The Mughals later captured Bangalore and sold it to Maharaja Devaraja Wodeyar II of the Kingdom of Mysore . [13] When Haider Ali seized control of the kingdom, the administration of Bangalore passed into his hands.