In 1738, Nader Shah and his forces captured Kandahar, the last Hotak stronghold, from Shah Hussain Hotak, at which point the incarcerated 16-year-old Ahmad Shah Durrani was freed and made the commander of an Afghan regiment. Soon after, the Persian and Afghan forces invaded India. By 1747, the Afghans chose Durrani as their head of state. Durrani and his Afghan army conquered much of present-day Afghanistan, Pakistan, the Khorasan and Kohistan provinces of Iran, and Delhi in India. He defeated the Indian Maratha Empire, and one of his biggest victories was the 1761 Battle of Panipat.