The tribal Afghans rode roughshod over their conquered territory for seven years but were prevented from making further gains by Nader Shah, a former slave who had risen to military leadership within the Afshar tribe in Khorasan, a vassal state of the Safavids. Quickly making a name as a military genius both feared and respected amongst the empire's friends and enemies (including Iran's archrival the Ottoman Empire, and Russia; both empires Nader would deal with soon afterwards), Nader Shah easily defeated the Afghan Hotaki forces in the 1729 Battle of Damghan. He had removed them from power and banished them from Iran by 1729. In 1732 by the Treaty of Resht and in 1735 Treaty of Ganja, he negotiated an agreement with the government of Empress Anna Ioanovna that resulted in the return of the recently annexed Iranian territories, making most of the Caucasus fall back into Iranian hands, while establishing an Irano-Russian alliance against the common neighbouring Ottoman enemy. In the Ottoman–Iranian War (1730–35), he retook all territories lost by the Ottoman invasion of the 1720s, as well as beyond. With the Safavid state and its territories secured, in 1738 Nader conquered the Hotaki's last stronghold in Kandahar; in the same year, in need of fortune to aid his military careers against his Ottoman and Russian imperial rivals, he started his invasion of the wealthy but weak Mughal Empire accompanied by his Georgian subject Erekle II, occupying Ghazni, Kabul, Lahore, and as far as Delhi, in India, when he completely humiliated and looted the militarily inferior Mughals. These cities were later inherited by his Abdali Afghan military commander, Ahmad Shah Durrani, who would go on to found the Durrani Empire in 1747. Nadir had effective control under Shah Tahmasp II and then ruled as regent of the infant Abbas III until 1736 when he had himself crowned shah.