Agra in Uttar Pradesh is the land of the world famous Taj Mahal. It was the glorious capital of the Mughals.
Sultan Sikandar Lodi (reign: 1489-1517) is often credited as the founder of the city of Agra. Sikandar was the second and most powerful ruler of the Afghan Lodi dynasty of Delhi.
Following were the reasons for building the new town:
The jagirdars of Dholpur, Gwalior and Malwa were in constant terror of the Rajput raids and they made continuous representations to the Sultan to protect them from this menace. In order to subjugate the rebels and bring Dholpur, Gwalior and Malwa under his complete control, Sikandar Lodi realized the necessity of establishing his army headquarters at a strategic place in the neighbourhood of those places. [Agra occupied the central position for all these states.] For finding the suitable site, Sikandar commissioned some of his officers to explore the shores of the river from Chandwar to Delhi. The commissioners at last arrived the spot where Agra now stands and thus the foundations of Agra were laid out in the year 1505. A strong fort was also built there.
Here's the detailed account of Khwaja Nimatullah regarding the foundation of Agra:
In 1505, the sultan resolved to translate this idea into action and to populate all the area so that it might become the seat of royalty, a place for the assemblage of troops and a base from which the rebels of the neighbourhood might be rendered obedient and submissive, trodden under foot and kept in subjugation. With this object in view, he deputed a number of wise, experienced and farsighted men to survey both banks of the river Yamuna and report a site that appeared suitable to them. They started from Delhi on board a vessel and floated downstream, surveying and reconnoitering until they arrived at the spot where Agra now stands. They selected this site and submitted a memorandum to the sultan who marched from Delhi to Mathura. Here he embarked on a boat and made a delightful journey, roaming about and hunting, until he reached Agra and sighted a high ground suitable for habitation. He asked the captain of the crews named Nayak, who piloted his barge which of the two areas of high ground ahead was more suited to his purpose. Nayak replied "That one in the foreground" (Ag-i-Rah). The sultan smiled and said "Let this town also be named Ag-rah". He recited the Fatiha and ordered the foundations to be laid at an auspicious hour. The city was founded on the outskirts of the villages of Bashi and Poiya within the Deoli pargana in Bayana sarkar. The fifty-two parganas constituting the above sarkar were incorporated into Agra which since that time has flourished greatly and has turned out to be the capital of the rulers of Hindustan.
History of Agra:
There are many stories and legends about the ancient city of Agra. According to Indian mythology, Agra fort is said to have been a state prison in the time of Raja Kans (uncle of Lord Krishna), ruler of Mathura.
Sikandar Lodi captured Agra along with Bayana [in Uttar Pradesh] in 1491-92. (Agra was then a dependancy of the pargana of Bayana and it was captured from Habibat Khan Jalwani, a vassal of Sultan Ashraf, also known as Sharf-ud-din Jalwani of Bayana). In 1505, he transferred the capital to Agra.
According to Abdullah, author of Tarikh-i-Daudi, Sikandar Lodi had only converted Agra into a city, before which it had been a small village. Many authors have recorded that there was a terrible earthquake took place at Agra on 6th July, 1505, and large buildings were totally destroyed. So there were already many lofty buildings at Agra, before Sikandar's occupation.
Abdullah adds that when Mahmud of Ghazni (reign: 998-1030) invaded Hindustan, it was totally ruined. This is wrong. In fact, it was prince Mahmud, a great-grandson of Mahmud of Ghazni, who had stormed the fort in 1080-81. Jahangir mentions this in his account of Agra:
Jahangir says that before the rule of the Lodi Afghans, Agra was a large, flourishing place with a strong fort, as Mas'ud Sa'd Salman mentions in a qasida in praise of his patron prince Mahmud, the son of Sultan Ibrahim of Ghazni, on the conquest of the above-mentioned fort. And when Sikandar Lodi designed to take Gwalior he came to Agra from Delhi, and settled down there. From that date the population and prosperity of Agra increased, and it became the capital of the Sultans of Delhi. "Agra had formerly an old fort on the bank of the Yamuna, but this my father threw down before my birth, and he founded a fort of cut red stone, the like of which those who have traveled over the world cannot point out", he remarks. Which old fort did Akbar demolish to built the Agra fort? Was it the same fort which was built by Sikandar Lodi?
Mahmud's Invasion of Agra:
Mahmud's invasion of Agra seems to have taken place about 1080-81. The Ghaznavid poet Mas'ud Sa'd Salman describes the ancient fort of Agra as 'built amongst the sand, like a hill, and the battlements of it are like hillocks..no calamity had ever befallen its fortifications'. On reaching Agra, prince Mahmud's forces attacked its ruler Jaipal and after several days of fierce fighting, the fortress was taken. Other local chiefs offered their submission and brought rich presents and elephants. The elephants were committed to the keeping of certain Chand Rai at Kannauj. Historian D.C Ganguly identifies Raja Jaipal of Agra as Gopala of the Rashtrakuta dynasty and Chand Rai of Kannauj as Chandradeva of the Gahadavala dynasty.
To sum up, Sikandar Lodi conquered Agra and made it his capital. We may conclude that Sikandar Lodi was the founder of modern Agra. From Sikandar's son Ibrahim, Agra passed into the hands of Babur.
*Some historians are in the opinion that Sikandar's Agra lay on the eastern or left bank of Yamuna, while Akbar's Agra is situated on its west or right bank.
Sikandra, the land of Akbar's tomb, is is another town built by Sikandar Lodi, near Agra. He also built a Baradari near Sikandra, which was converted into a tomb by the Mughals. It is believed to be the tomb of Mariam Zamani.
The Province of Agra: Its History and Administration By Dharma Bhanu
The Historical Value of Diwan-i-Salman By Ganguly, D.C.
Tarikh-i-Khan Jahani Wa Makhzan-i-Afghani. A complete history of the Afghans in Indo-Pak sub-continent, of Khwaja Nimatullah
The Memoirs of Emperor Jahangir written by Himself
History of India, as Told by Its Own Historians By Elliot & Dowson