Answer:
In 1001 Mahmud of Ghazni first invaded modern day Pakistan and then parts of India. Mahmud defeated, captured, and later released the Hindu Shahi ruler Jayapala, who had moved his capital to Peshawar (modern Pakistan). Jayapala killed himself and was succeeded by his son Anandapala.