In 1707, Kandahar was in a state of chaos, fought over by the Safavid state of and the Mughal state of India. Mirwais Khan, a Pashtun tribal chief whose influence with his fellow-countrymen made him an object of suspicion, was held as a political prisoner by Gurgin Khan, the Persian governor in the region, who then sent him to the Safavid court at Isfahan. He was later freed and even allowed to meet with the Shah, Sultan Husayn, on a regular basis. Having ingratiated himself with the Persian court, Mirwais sought and obtained permission to perform the pilgrimage to Mecca in the Ottoman Empire. At that time the once powerful Safavids were declining politically and militarily, riven by internal strife, royal intrigues, and endless wars against their arch rivals, the Ottomans. During his time in Persia, Mirwais, cleverly, tried to learn all the military weaknesses of the Safavids. and Mughal period While in Mecca, he sought a fatwa from the leading religious authorities against the foreign rulers who were persecuting his people in his homeland. The Pashtun tribes rankled under the ruling Safavids because of their continued attempts to forcefully convert them from Sunni to Shia Islam. The fatwa was granted and he carried it with him to Iṣfahan and subsequently to Kandahar, with permission to return and strong recommendations to Gurgin Khan. He began organizing the Pashtun tribes for a major uprising, and in April 1709, when a large part of the Persian garrison was on an expedition outside the city, he and his followers fell on the remainder and killed the majority of them, including Gurgin Khan. With the death of Gurgin Khan, the Hotaki Pashtuns immediatley took control of the city by force and then the province. Mirwais entered Kandahar and made an important speech to its inhabitants: Mirwais and his forces then defeated a large Persian army that was sent to regain control over the area. Mirwais Khan became the governor of the Greater Kandahar region. To the northwest were the AbdaliPashtun tribe and to the east lay the Moghul Empire. Refusing the title of king humbly, Mirwais was referred to as "Prince of Kandahár and General of the national troops" by his Pashtun countrymen.
Mirwais remained in power until his death in November 1715 and was succeeded by his brother Abdul Aziz, who was later killed by Mirwais' son Mahmud, allegedly for planning to give Kandahar's sovereignty back to Persia. In 1717, Mahmud took advantage of the political weakness of the Persian Shah and briefly conquered large parts Persia. Mirwais is buried in his mausoleum in the Kokaran section of Kandahar, which is in the western end of the city. He is regarded as one of Afghanistan's greatest national heroes and admired by many people, especially the Pashtuns. Steven Otfinoski referred to him as Afghanistan's George Washington in his 2004 book Afghanistan. Many places were named after him in honour. There is a neighborhood called Mirwais Mina as well as a hospital called Mirwais Hospital, a high school and a business center named after him in Kandahar. There are also schools and a number of institutions or places across Afghanistan built to honor him. A few direct descendants of Mirwais are living today among the Pashtun Hotak tribe.