The Siege of Herat was part of the Islamic conquest of Persia. Caliph Umar (634-644 CE) launched an offensive against the Sassanid Persian Empire in 642 and by 651 the Empire was destroyed and almost all parts of Persia was conquered, except parts of Khorasan which was still held by Sasanian loyalists and their Hephthalite allies. A veteran military commander, Ahnaf ibn Qais, was appointed by the caliph for the conquest of Khurasan, which in those time comprises most of present-day north eastern Iran, Afghanistan and Turkmenistan. In 652, he defeated the ruler of Herat and made a treaty with him. However, the ruler of Herat along with the Karenids and many other natives of Khorasan, later rebelled against the Arabs, but were defeated at the battle of Badghis.