Ildegiz, atabeg of Azerbaijan, was determined to oust the amir of Ray, Inanj Sonqur, who had challenged his attempt to install his stepson Arslan-Shah (Arslan ibn Toghril, grandson of Muhammad) as Sultan of Iran.