Zaynab an-Nafzawiyyah

Zaynab an-Nafzāwiyyah () (fl. 1075), was a Berber woman of influence in the early days of the Almoravid Berber empire which gained control of Morocco, Algeria, and parts of Spain.
She was married to Yusuf ibn Tashfin (r. 1061-1107) and reportedly his de facto co-ruler. She was one of the wives of Berber kings given the title of "malika" (queen), which was not a given thing for the wives of Muslim monarchs, and called "al-qa'ima bi mulkihi" ('literally: the one in charge of her husband's mulk'), referring to her participation in the state affairs during the reign of her spouse. Though the "khutba" was never issued in her name, she was recognized to share the power of her spouse.
Life.
The earliest reference to her is in the anonymous 12th-century text "Kitab al-Istibsar", where it says "In her time there was none more beautiful or intelligent or witty ... she was married to Yusuf, who built Marrakech for her". This work names her father as Ibrāhīm an-Nafzāwi, a merchant originally from Kairouan.
According to Ibn Khaldun, she first became the concubine of Yusuf ibn Ali, chief of the Wurika and Aylana Berber tribes about Aghmat in Morocco. She then married Luqūt al-Maghrāwi, amir of Aghmat. Luqūt was killed in a battle against the invading Almoravids and his wealth was inherited by Zaynab.
The most detailed information appears to be in the (unfortunately incomplete) early 14th-century text "Al-bayan al-mughrib". She is said to have had many offers of marriage from tribal chiefs from all over Morocco, but always declined by saying she would marry no-one who did not wish to become ruler of the whole country. It is said she had supernatural powers, and conversed with genies.
She married the Almoravid leader, Abu-Bakr Ibn-Umar in September 1068 and offered to put her immense wealth at his disposal. It is said she blindfolded Abu Bakr, then led him to a secret cavern. When she removed the blindfold, he saw around him an immense treasure of gold and silver, pearls and rubies. "All this is yours" she said before leading him out - again blindfolded.
Abu Bakr began the construction of Marrakech in May 1070. Work had not progressed very far when a messager arrived pleading for his help in suppressing a revolt against the Almoravids deep in the Sahara Desert. Abu Bakr knew that his wife was not suited to the rigours of a desert life, and divorced Zaynab, advising her to marry Yusuf ibn Tashfin, whom he was leaving as his deputy. He departed for the Sahara in January 1071, and after the legal period of 3 months' separation had ended, Zaynab duly married Yusuf in May of that year. It says that Yusuf owed the conquest of the Maghreb (Morocco, Algeria and Spain) to her advice, and that she was so expert in conducting negotiations that she was nicknamed "The Magician".
In 1072, Abu Bakr signalled his intention to return from the Sahara to take up his former position. Yusuf was understandably reluctant to yield, but did not know how to keep his position without triggering an internecine war with Abu Bakr. It is said that Zaynab, knowing of Abu Bakr's fondness for the desert life and his own reluctance to cause unwarranted bloodshed, advised Yusuf to confront Abu Bakr in a firm but courteous manner, and mollify him with luxurious presents. This Yusuf did, and the meeting passed without incident. Abu Bakr returned to the Sahara, but in a continuing homage his name remained on Almoravid coinage until his death some years later.
Zaynab is known to have had at least two sons by Yusuf:
The "Rawd al-Qirtas" gives the date of her death as 1071, which does not fit with more accurate sources, in which she would realistically have been alive to at least 1075.
Legacy.
Her example and the fact that she assisted in creating the dynasty and its customs had great impact on the situation of women in Almoravid Morocco. In the tradition and example of her, women in Morocco had high status during the reign of the Almoravid dynasty; princesses were allowed to participate in state affairs; women in Morocco did not wear veils; the education of women was accepted and normal, with notable women such as Hafsa Bint al-Hajj al-Rukuniyya holding courses for the women of the palace; at least two women known to have been doctors, and, finally, princess Fannu famously participated in the defense of the capital during the dynasty's downfall in 1147.