After the assassination of Nader Shah Afshar in 1747, Ahmad Shah Durrani was chosen as King of Afghanistan. Rallying his Afghan tribes and allies, he pushed east towards the Mughal and the Maratha empires of India, west towards the disintegrating Afsharid Empire of Persia, and north toward the Khanate of Bukhara. Within a few years, he extended his control from Khorasan in the west to Kashmir and North India in the east, and from the Amu Darya in the north to the Arabian Sea in the south.
Durrani was born in or about 1722 to Mohammad Zaman Khan, chief of the Abdali tribe and Governor of Herat, and Zarghuna Alakozai. There has been some debate about Durrani's exact place of birth. Most believe that he was born in Herat, Afghanistan. He was born as Ahmed Khan. Abdali's father suffered "Persian captivity for many years" at Kirman before being released from prison in 1715. As a refugee, he "made his way to India" and joined his kinsmen at Multan. After he raised his family there, he was recognized as the "scion of hereditary Sadozai chiefs". It is believed that Zaman Khan returned to Afghanistan to fight the Persians and his Afghan rivals, but left one of his wives at Multan because she was "in the family way". So other sources believe that, Abdali was born at Multan in 1722, after which she returned to Afghanistan to reunite with her husband. He lost his father during his infancy.
Durrani's forefathers were Sadozais but his mother was from the Alakozai tribe. In June 1729, the Abdali forces under Zulfiqar had surrendered to Nader Shah Afshar, the rising new ruler of Persia. However, they soon began a rebellion and took over Herat as well as Mashad. In July 1730, he defeated Ibrahim Khan, a military commander and brother of Nader Shah. This prompted Nader Shah to retake Mashad and also intervene in the power struggle of Harat. By July 1731, Zulfiqar returned to his capital Farah where he had been serving as the governor since 1726. A year later Nadir's brother Ibrahim Khan took control of Farah. During this time Zulfiqar and the young Durrani fled to Kandahar where they took refuge with the Ghiljis. They were later made political prisoners by Hussain Hotak, the Ghilji ruler of the Kandahar region.
Nader Shah had been enlisting the Abdalis in his army since around 1729. After conquering Kandahar in 1738, Durrani and his brother Zulfiqar were freed and provided with leading careers in Nader Shah's administration. Zulfiqar was made Governor of Mazandaran while Durrani remained working as Nader Shah's personal attendant. The Ghiljis, who are originally from the territories east of the Kandahar region, were expelled from Kandahar in order to resettle the Abdalis along with some Qizilbash and other Persians.