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 at 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.
It was only during the reign of Akbar’s grandson, Shah Jahan, that the site took on its current state. Legend has it that Shah Jahan built the beautiful Taj Mahal for his wife, Mumtaz Mahal. Unlike his grandfather, Shah Jahan tended to have buildings made from white marble, often inlaid with gold or semi-precious gems. He destroyed some of the earlier buildings inside the fort to make his own.
At the end of his life, Shah Jahan was deposed and restrained by his son, Aurangzeb, in the fort. It is rumoured that Shah Jahan died in Muasamman Burj, a tower with a marble balcony with a view of the Taj Mahal.