The present-day structure was built by the Mughals, though a fort had stood there since at least the 11th century. Agra Fort was originally a brick fort known as Badalgarh, held by Raja Badal Singh Hindu Sikarwar Rajput king (c. 1475). It was mentioned for the first time in 1080 AD when a Ghaznavide force captured it. Sikandar Lodi (1488–1517) was the first Sultan of Delhi who shifted to Agra and lived in the fort. He governed the country from here and Agra assumed the importance of the second capital. He died in the fort in 1517 and his son, Ibrahim Lodi, held it for nine years until he was defeated and killed at Panipat in 1526. Several palaces, wells and a mosque were built by him in the fort during his period.