Quba Khanate
According to Mirza Ahmad Mirza oglu Khudaverdi, the founder of the Talysh Khanate, Seyyid Abbas, his ancestors were members of the Safavid dynasty, who had moved into the Talish region during the 1720s during a turbulent period in Iranian history. When Seyyid Abbas died in 1747 he was succeeded by his son Jamaladdin, often remembered as "Gara Khan" (the 'Black King'), because of his dark skin. Because of his good service to Nader Shah, Nader officially awarded him the hereditary title of "khan". Gara Khan was pro-Russian in his foreign policy which upset the rulers of neighboring khanates notably Hidayat Khan of Gilan. In 1768 Hidayat Khan attacked the Talysh khanate. Seeking aid against the superior enemy, Gara Khan sent his brother Karbalayi Sultan to Fath Ali Khan, ruler of the Quba Khanate resulting in an alliance between Quba and Lankaran. By 1785 the territory of the Talysh khanate had formally become a dependency of that much stronger Quba Khanate together with certain other Azerbaijani khanates. However, in 1789 following Fath Ali Khan's death, the Talysh Khanate regained its independence under Mir Mustafa, the son of Gara Khan who had himself died in 1786.