The Mughal Empire at its peak extended over nearly all of the Indian subcontinent and parts of Afghanistan. It was the second largest empire to have existed in the Indian subcontinent, spanning approximately four million square kilometres at its zenith, after only the Maurya Empire, which spanned approximately five million square kilometres. The Mughal Empire ushered in a period of proto-industrialization, and around the 17th century, Mughal India became the world's largest economic power, accounting for 24.4% of world GDP, and the world leader in manufacturing, producing 25% of global industrial output up until the 18th century. The Mughal Empire is considered "India's last golden age" and one of the three Islamic Gunpowder Empires (along with the Ottoman Empire and Safavid Persia).
The beginning of the empire is conventionally dated to the victory by its founder Babur over Ibrahim Lodi, the last ruler of the Delhi Sultanate, in the First Battle of Panipat (1526). The Mughal emperors had roots in the Turco-Mongol Timurid dynasty of Central Asia, claiming direct descent from both Genghis Khan (founder of the Mongol Empire, through his son Chagatai Khan) and Timur (Turco-Mongol conqueror who founded the Timurid Empire). During the reign of Humayun, the successor of Babur, the empire was briefly interrupted by the Sur Empire. The "classic period" of the Mughal Empire started in 1556 with the ascension of Akbar the Great to the throne. Under the rule of Akbar and his son Jahangir, the region enjoyed economic progress as well as religious harmony, and the monarchs were interested in local religious and cultural traditions. Akbar was a successful warrior who also forged alliances with several Hindu Rajput kingdoms. Some Rajput kingdoms continued to pose a significant threat to the Mughal dominance of northwestern India, but most of them were subdued by Akbar. All Mughal emperors were Muslims; Akbar, however, propounded a syncretic religion in the latter part of his life called Dīn-i Ilāhī, as recorded in historical books like Ain-i-Akbari and Dabistān-i Mazāhib.
The Mughal Empire did not try to intervene in the local societies during most of its existence, but rather balanced and pacified them through new administrative practices and diverse and inclusive ruling elites, leading to more systematic, centralised, and uniform rule. Traditional and newly coherent social groups in northern and western India, such as the Marathas, the Rajputs, the Pashtuns, the Hindu Jats and the Sikhs, gained military and governing ambitions during Mughal rule, which, through collaboration or adversity, gave them both recognition and military experience.
The reign of Shah Jahan, the fifth emperor, between 1628 and 1658, was the zenith of Mughal architecture. He erected several large monuments, the best known of which is the Taj Mahal at Agra, as well as the Moti Masjid, Agra, the Red Fort, the Badshahi Mosque, the Jama Masjid, Delhi, and the Lahore Fort. The Mughal Empire reached the zenith of its territorial expanse during the reign of Aurangzeb and also started its terminal decline in his reign due to Maratha military resurgence under Shivaji Bhosale. During his lifetime, victories in the south expanded the Mughal Empire to its greatest extent, ruling over more than 150 million subjects, nearly one quarter of the world's population at the time, with a GDP of over $90 billion.
By the mid-18th century, the Marathas had routed Mughal armies and won over several Mughal provinces from the Punjab to Bengal. Internal dissatisfaction arose due to the weakness of the empire's administrative and economic systems, leading to its break-up and declarations of independence of its former provinces by the Nawab of Bengal, the Nawab of Awadh, the Nizam of Hyderabad and other small states. In 1739, the Mughals were crushingly defeated in the Battle of Karnal by the forces of Nader Shah, the founder of the Afsharid dynasty in Persia, and Delhi was sacked and looted, drastically accelerating their decline. During the following century Mughal power had become severely limited, and the last emperor, Bahadur Shah II, had authority over only the city of Shahjahanabad. He issued a firman supporting the Indian Rebellion of 1857 and following the defeat was therefore tried by the British East India Company for treason, imprisoned and exiled to Rangoon. The last remnants of the empire were formally taken over by the British, and the Government of India Act 1858 let the British Crown formally assume direct control of India in the form of the new British Raj.