All the three lines appear to have been descended from the Hamdan tribe, just like the Ismaili Sulayhid dynasty who ruled Yemen and were adherents of the Egyptian Fatimid caliphs. The Sulayhid capital was moved from San'a to Jibla in 1088, and a Hamdan tribesman called Imran bin al-Fadl was appointed governor of the city together with the king's uncle As'ad bin Shihab. When the Sulayhid da'i or leader Saba' bin Ahmad died in 1098, control over San'a passed to the powerful tribal leader Hatim bin al-Ghashim al-Mughallasi who took the titlesultan. Hatim established the power of the Hamdanids together with his eldest son Muhammad. However, he soon found reason to kill his son, who was given to murdering beautiful young girls. When Hatim died in 1109, he was therefore succeeded by his second son Abdallah, who was poisoned in 1111. His younger brother Ma'an then came to power. Ma'an was deposed and imprisoned in 1116 by the Qadi Ahmad, son of governor Imran, since he was too weak to uphold authority over the Hamdan sub-tribes. Hisham, al-Humas and Hatim, belonging to the al-Qubaib line of the Hamdanids, then maintained power until 1139. Under Hatim there was tribal discord and the people of San'a rose in revolt. The son of qadi Ahmad bin Imran, Hamid ad-Dawla Hatim, entered the city with 700 Hamdani horsemen and was established as sultan. Banu Zuwahi, offered mountain-peak fortress of Kawkaban near San’aa to Syedna Hatim in 561/1166. San’aa was under the rule of Sultan Ali b. Hatim al-Yami of the Hamdan tribe. Perceiving a threat to his own sovereignty, Sultan Ali proceeded to lay siege to Kawkaban. A trusted associate of the Dai Ahmad al-Hibri betrayed him. Ahmad al-Hibri accepted a bribe from Sultan Ali, gave him vital information about the Dai’s arrangements, and persuaded others in Kawkaban to turn against him, and forced Hatim to left Kawkaban. He went to Lu’lu’a and Ray’an, two smaller fortresses some distance away. But Sultan Ali pursued him there with his troops and the Dai’s reluctance to cause further strife among the Hamdan qabila prompted him to relinquish his hopes for acquiring territories in the San’aa region. He decided to move to the mountainous Haraz region, where there had been Ismailis from the time of the first Sulayhid ruler. In the next few years a series of successful military expeditions gradually brought most of Haraz under the Dai’s control. The core of his army was the Ya’aabir qabila, and their chief Amir Sabaa b. Yusuf.
After the end of Sulayhid rule in Yemen, the country was split between a number of competing petty dynasties along tribal and religious lines. The Zaidiyyahimamate, extinct since 1066, was revived in the person of al-Mutawakkil Ahmad bin Sulayman. From his base in Sa'dah he marched against San'a in 1150 and defeated Hamid ad-Dawla Hatim, but was unable to secure the city. Hamid ad-Dawla was able to maintain his position until his death in 1161. His son and successor Ali bin Hatim was able to expand the power base of the dynasty in northern Yemen. Military victories alternated with defeats, but in 1173 he allied with the Zurayids of Aden and worsted the religiously deviant Mahdidregime. However, hardly had Ali bin Hatim returned to San'a when a new external threat appeared. The Ayyubid ruler in Egypt, Saladin sent his brotherTuran Shah with an army to South Arabia in the same year. When the Ayyubids reached the outskirts of San'a, Ali bin Hatim fled to a mountain fortress, leaving San'a to be captured in August 1174. Thus ended the rule of Fatimid-affiliated dynasties in San'a. Turan Shah occupied Yemen and ruled there until 1181. Ali bin Hatim nevertheless continued to offer periodic resistance until 1197, and was able to hold San'a for long periods when there was no Ayyubid army around. In 1197 he offered his allegiance to the new Zaydiyyah imam al-Mansur Abdallah.