Ahmad Sanjar
Qarin III's refusal to submit to the Seljuq atabeg of Ray, made the atabeg offer Ali an opportunity to conquer Mazandaran, to which he agreed. Shahriyar quickly sided with Qarin III and convinced Ali to withdraw. Nevertheless, the strife continued between the two brothers. Ali later went to Marw and joined the Seljuq prince Ahmad Sanjar, the ruler of Khorasan. Ahmad Sanjar was preparing for an expedition to the west in order to take control of Gorgan, but an attack made by Muhammad Khan on the Seljuq borders, forced Ahmad Sanjar to move east in order to repel Muhammad Khan. This allowed Qarin III to capture Gorgan while Shahriyar stayed in Tamisha.