Buyid dynasty
During the mid-11th century, the Buyid amirates gradually fell to the Ghaznavid and Seljuq Turks. In 1029, Majd al-Dawla, who was facing an uprising by his Daylami troops in Ray, requested assistance from Mahmud of Ghazna. When Sultan Mahmud arrived, he deposed Majd al-Dawla, replaced him with a Ghaznavid governor and ended the Buyid dynasty in Ray.