<P> In 1398, Timur Lang invaded India on the pretext that the Muslim sultans of Delhi were too tolerant of their Hindu subjects . After defeating the armies of Nasiruddin Mahmud of Tughlaq dynasty, on 15 December 1398, Timur entered Delhi on 18 December 1398, and the city was sacked, destroyed, and left in ruins, and over 100,000 war prisoners were killed as well . In 1526, following the First Battle of Panipat, Zahiruddin Babur, the former ruler of Fergana, defeated the last Afghan Lodi sultan and founded the Mughal dynasty which ruled from Delhi, Agra and Lahore . </P> <P> In the mid-16th century there was an interruption in the Mughal rule of India as Sher Shah Suri defeated Babur's son Humayun and forced him to flee to Persia . Sher Shah Suri built the sixth city of Delhi, as well as the old fort known as Purana Qila, even though this city was settled since the ancient era . After Sher Shah Suri's death in 1545, his son Islam Shah took the reins of north India from Delhi . Islam Shah ruled from Delhi till 1553 when Hindu king Hem Chandra Vikramaditya, also called Hemu, became the Prime Minister and Chief of Army of Adil Shah . Hem Chandra fought and won 22 battles in all against rebels and twice against Akbar's army in Agra and Delhi, without losing any . After defeating Akbar's army on 7 October 1556 at Tughlakabad fort area in Battle of Delhi (1556), Hemu acceded to Delhi throne and established Hindu Raj in North India for a brief period, and was bestowed with the title' Vikramaditya', at his coronation in Purana Quila, Delhi . </P> <P> The third and greatest Mughal emperor, Akbar, moved the capital to Agra, resulting in a decline in the fortunes of Delhi . In the mid-17th century, the Mughal Emperor Shah Jahan (1628--1658) built the city that sometimes bears his name Shahjahanabad, the seventh city of Delhi that is more commonly known as the old city or old Delhi . This city contains a number of significant architectural features, including the Red Fort (Lal Qila) and the Jama Masjid . The old city served as the capital of the later Mughal Empire from 1638 onwards, when Shah Jahan transferred the capital back from Agra . Aurangzeb (1658--1707) crowned himself as emperor in Delhi in 1658 at the Shalimar garden (' Aizzabad - Bagh) with a second coronation in 1659 . After 1680, the Mughal Empire's influence declined rapidly as the Hindu Maratha Empire rose to prominence . </P> <P> In 1737, Bajirao I marched towards Delhi with a huge army . The Marathas defeated the Mughals in the First Battle of Delhi . The Maratha forces sacked Delhi following their victory against the Mughals . In 1739, the Mughal Empire lost the huge Battle of Karnal in less than three hours against the numerically outnumbered but military superior Persian army led by Nader Shah during his invasion after which he completely sacked and looted Delhi, the Mughal capital, followed by massacre for 2 days, killing over 30,000 civilians and carrying away immense wealth including the Peacock Throne, the Daria - i - Noor, and Koh - i - Noor . Nader eventually agreed to leave the city and India after forcing the Mughal emperor Muhammad Shah I to beg him for mercy and granting him the keys of the city and the royal treasury . A treaty signed in 1752 made Marathas the protector of the Mughal throne at Delhi . </P>

Which mughal emperor shifted capital from agra to delhi