The Karamanids (Karamanoğulları or Karamanoğulları Beyliği), also known as the Emirate of Karaman and Beylik of Karaman (Karamanoğulları Beyliği), was one of the Anatolian beyliks, centered in South-Central Anatolia around the present-day Karaman Province. From the mid 14th century until its fall in 1487, the Karamanid dynasty was one of the most powerful beyliks in Anatolia. The Karamanids traced their ancestry from Hodja Sad al-Din and his son Nure Sufi Bey, who emigrated from Arran (roughly encompassing modern-day Azerbaijan) to Sivas because of the Mongol invasion in 1230. The Karamanids were members of the Salur tribe of Oghuz Turks. According to Muhsin Yazıcıoğlu and others, they were members of the Afshar tribe, which participated in the revolt led by Baba Ishak and afterwards moved to the western Taurus Mountains, near the town of Larende, where they came to serve the Seljuks. Nure Sofi worked there as a woodcutter. His son, Kerîmeddin Karaman Bey, gained a tenuous control over the mountainous parts of Cilicia in the middle of the 13th century. A persistent but spurious legend, however, claims that the Seljuq Sultan of Rum, Kayqubad I, instead established a Karamanid dynasty in these lands. Karaman Bey expanded his territories by capturing castles in Ermenek, Mut, Ereğli, Gülnar, and Silifke. The year of the conquests is reported as 1225, during the reign of Ala al-Din Kaykubadh I (1220–1237), which seems excessively early. Karaman Bey's conquests were mainly at the expense of the Kingdom of Lesser Armenia (and perhaps at the expense of Rukn al-Din Kilij Arslan IV, 1248–1265); in any case it is certain that he fought against the Kingdom of Lesser Armenia (and probably even died in this fight) to such extent that King Hethum I (1226–1269) had to place himself voluntarily under the sovereignty of the great Khan, in order to protect his kingdom from Mamluks and Seljuks (1244). The rivalry between Kilij Arslan IV and Izz al-Din Kaykaus II allowed the tribes in the border areas to live virtually independently.