The Arab conqueror Muhammad bin Qasim conquered Sindh in 711 CE. The Pakistan government's official chronology claims this as the time when the foundation of Pakistan was laid but the concept of ''Pakistan'' arrived in the 19th century. The Early Medieval period (642–1219 CE) witnessed the spread of Islam in the region. During this period, Sufi missionaries played a pivotal role in converting a majority of the regional Buddhist and Hindu population to Islam. Upon the defeat of the Turk and Hindu Shahi dynasties which governed the Kabul Valley, Gandhara (present-day Khyber Pakhtunkwa), and western Punjab in the 7th to 11th centuries CE, several successive Muslim empires ruled over the region, including the Ghaznavid Empire (975–1187 CE), the Ghorid Kingdom, and the Delhi Sultanate (1206–1526 CE). The Lodi dynasty, the last of the Delhi Sultanate, was replaced by the Mughal Empire (1526–1857 CE).