Abu'l-Qasim al-Husayn ibn Ali al-Maghribi (Aleppo, May 981 – Mayyafariqin, 1027), also called al-wazir al-Maghribi ("the Western Vizier") and by the surname al-Kamil Dhu'l-Wizaratayn ("Perfect Possessor of the Two Vizierates"), was the last member of the Banu'l-Maghribi, a family of statesmen who served in several Muslim courts of the Middle East in the 10th and early 11th centuries. Abu'l-Qasim himself was born in Hamdanid Aleppo before fleeing with his father to Fatimid Egypt, where he entered the bureaucracy. After his father's execution, he fled to Palestine, where he raised the local Bedouin leader Mufarrij ibn Daghfal to rebellion against the Fatimids (1011–13). As the rebellion began to falter, he fled to Iraq, where he entered the service of the Buyid emirs of Baghdad. Soon after he moved to the Jazira, where he entered the service of the Uqaylids of Mosul and finally the Marwanids of Mayyafariqin. He was also a poet and author of a number of treatises, including a "mirror for princes".
Abu'l-Qasim al-Husayn was the son of Abu'l-Hasan Ali ibn al-Husayn al-Maghribi, himself the grandson of the family's founder, Abu'l-Hasan Ali ibn Muhammad al-Maghribi, a Persian official who had originally served at the Abbasid court of Baghdad as head of the diwan al-maghrib, the "Bureau of the West", whence the family's nisbah of "al-Maghribi". In the late 940s, Abu'l-Qasim's grandfather entered the service of the Hamdanid Emirate of Aleppo, serving as a secretary (katib) under Emir Sayf al-Dawla (r. 946–967), a post to which he was followed by Abu'l-Qasim's father Ali.