Al-Khayzuran was also the first woman to have her own bureaucracy and court and accept petitions and the audience of officials and the people, and to command and forbid in the caliphate.
While al-Mahdi spent most of his time hunting and having fun, she, by influencing the court, was able to hold meetings in her house to run the caliphate.
At the time of al-Mahdi's untimely death, al-Khayzuran in the capital (Baghdad) had already taken over government affairs and by hiding his death and paying the salaries of army officers, she secured the allegiance of the soldiers for her son al-Hadi as the new caliph, but al-Hadi opposed his mother in sharing and partnership unquestionable power in the caliphate, and al-Khayzuran killed him after severe disputes.
At that time the woman slaves of the harem, called jarya or jawari, were famed for educating themselves in music, singing, astrology, mathematics and theology in order to keep their master's interest, and Al-Khayzuran took regular lessons in fiqh from the most learned qadis.
Al-Khayzuran had direct access to the caliph at all times: her suggestions were always adopted, individuals she recommended were favored and promoted, and at her intercession he forgave enemies or commuted death sentences.
During Al-Mahdi's reign, Al-Khayzuran held an extraordinary and unusual degree of power for anyone, let alone a woman: she discussed and helped decide all military and state affairs, she was not secluded in the harem, her influence over al-Mahdi allowed her to exercise political power outside of the harem over everyone and anything or everywhere, she met petitioners, both men and women, who asked her for favors or to intercede on their behalf with her husband, the caliph.
Al-Mahdi even allowed her to meet with foreign ambassadors and sign official papers for the administration of the empire.
[1] Al-Khayzuran's palace, like the caliph's, was guarded by soldiers and her lands spread past the outskirts of the capital, and she also ran a number of enterprises and factories through agents who reported directly to her, she also had a large business abroad and the much merchants and nobles of the capital and its suburbs depended on her; she owned hundreds of slaves, had many female attendants, and commanded a luxurious lifestyle.
[1] One time when Khaizuran was in her flat encircled by other imperial women, a servant notificed her that Muznah, the widow of Marwan II, the last Umayyad caliph, was at the door.
[3][clarification needed] In 785, Al-Mahdi died during an expedition with his son Harun, who rushed back to Baghdad to inform her.
[5] Despite his opposition, Al-Hadi did not manage to disturb his mother's extraordinary authority base, and she refused to retire from politics into the harem.
[1] One reason given is that she learned that he was planning to kill his brother Harun al-Rashid, another that he attempted to poison her himself, which she discovered after first allowing her dog to eat of the dish he had sent to her.
[1] Her second son, caliph Harun al-Rashid, in contrast to his brother, did not oppose to his mother participating in the affairs of state, but instead openly acknowledged her political ability and publicly trusted her advice, and governed the realm by her side.
Al-Khayzuran and her strong personality is believed by many literary historians to be a key influence on Scheherazade,[citation needed] the main character in One Thousand and One Nights.