<P> Babur, was a descendant of Genghis Khan and Timur, from the Fergana Valley in modern - day Uzbekistan . In 1526, he invaded India, defeated the last Lodhi sultan in the First Battle of Panipat and founded the Mughal Empire that ruled from Delhi and Agra . The Mughal dynasty ruled Delhi for more than three centuries, with a sixteen - year hiatus during the reigns of Sher Shah Suri and Hemu from 1540 to 1556 . In 1553, the Hindu king Hemu acceded to the throne of Delhi by defeating forces of Mughal Emperor Humayun at Agra and Delhi . However, the Mughals re-established their rule after Akbar's army defeated Hemu during the Second Battle of Panipat in 1556 . Shah Jahan built the seventh city of Delhi that bears his name Shahjahanabad, which served as the capital of the Mughal Empire from 1638 and is today known as the Old City or Old Delhi . </P> <P> After the death of Aurangzeb in 1707, the Mughal Empire's influence declined rapidly as the Hindu Maratha Empire from Deccan Plateau rose to prominence . In 1737, Maratha forces sacked Delhi following their victory against the Mughals in the First Battle of Delhi . In 1739, the Mughal Empire lost the huge Battle of Karnal in less than three hours against the numerically outnumbered but militarily superior Persian army led by Nader Shah of Persia . After his invasion, he completely sacked and looted Delhi, carrying away immense wealth including the Peacock Throne, the Daria - i - Noor, and Koh - i - Noor . The Mughals, severely further weakened, could never overcome this crushing defeat and humiliation which also left the way open for more invaders to come, including eventually the British . 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 protectors of the Mughal throne in Delhi . </P> <P> In 1757, the Afghan ruler, Ahmad Shah Durrani, sacked Delhi . He returned to Afghanistan leaving a Mughal puppet ruler in nominal control . The Marathas again occupied Delhi in 1758, and were in control until their defeat in 1761 at the third battle of Panipat when the city was captured again by Ahmad Shah . However, in 1771, the Marathas established a protectorate over Delhi when the Maratha ruler, Mahadji Shinde, recaptured Delhi and the Mughal Emperor Shah Alam II was installed as a puppet ruler in 1772 . In 1783, Sikhs under Baghel Singh captured Delhi and Red Fort but due to the treaty signed, Sikhs withdrew from Red Fort and agreed to restore Shah Alam II as the emperor . In 1803, during the Second Anglo - Maratha War, the forces of British East India Company defeated the Maratha forces in the Battle of Delhi . </P> <P> During the Indian Rebellion of 1857, Delhi fell to the forces of East India Company after a bloody fight known as the Siege of Delhi . The city came under the direct control of the British Government in 1858 . It was made a district province of the Punjab . In 1911, it was announced that the capital of British held territories in India was to be transferred from Calcutta to Delhi . The name "New Delhi" was given in 1927, and the new capital was inaugurated on 13 February 1931 . New Delhi, also known as Lutyens' Delhi, was officially declared as the capital of the Union of India after the country gained independence on 15 August 1947 . During the partition of India, thousands of Hindu and Sikh refugees, mainly from West Punjab fled to Delhi, while many Muslim residents of the city migrated to Pakistan . Migration to Delhi from the rest of India continues (as of 2013), contributing more to the rise of Delhi's population than the birth rate, which is declining . </P>

When delhi was declared as capital of india