The Barmakids were the wealthiest, most important family during early Abbasid years. “Barmak” may have been a hereditary title for the guardians of a Buddhist shrine in Balkh. The family converted to Islam very early and became part of the government. With their wealth, they supported the Abbasid revolution, and the family came to the new city of Baghdad as courtiers.
During Mansur’s reign, father Khalid and son Yahya were often sent as administrators to far-off cities in Iran, where they were faithful and efficient. In the city of Rayy, Yahya met Mansur’s son Mahdi, and their wives seem to have become friends. Both wives foster-nursed the other’s newborn son, a year apart. So the sons grew up as close friends. Both Mahdi and Yahya had two sons: Musa and Harun for the Caliph, and Fadl and Jafar for the vizier. (Mahdi had more sons, but only those two count in the story.)
Yahya became the all-powerful judge and fixer, the man who got done in a day more than other men in a week. He fixed canals and built levees against flooding, listened to hundreds of petitioners every day, and arranged for wheat from Egypt to be shipped to the Prophet’s cities of Mecca and Medina, to alleviate their comparative poverty. He also commissioned translation of scientific works from Greek and Sanskrit. He was also tutor to the Caliph’s younger son, Harun.
In 785, Mahdi died in a freak hunting accident, and the older son Musa became Caliph al-Hadi, and in Arab fashion it was stipulated that his brother Harun was his successor. Yahya ensured that when Musa al-Hadi died unexpectedly, Harun became Caliph al-Rashid.
Fadl was appointed governor of Khurasan (he seems to have done a very good job), but Jafar stayed in Baghdad. All three, Yahya, Fadl and Jafar played key roles in administration in the Abbasid state, but Jafar was the one who spent evenings with the Caliph listening to music or talking. In the Arabian Nights stories, Jafar is the Caliph’s companion when they disguise themselves and go out into the city. The Caliph even had Jafar contract a technical marriage with his sister, Abbasa, so that the three of them could spend time alone (and probably in Raqqa, which Harun preferred to Baghdad, despite the stories!).
The Caliph had two sons, Muhammad al-Amin and Abdallah al-Mamun, and he had court officials swear loyalty to both sons, which gave him a stable succession of two heirs. Al-Amin was the son of an Abbasid princess, Harun’s cousin, but al-Mamun’s mother was probably Khurasani. That made her son interesting to the far eastern power base. Jafar was appointed tutor to al-Mamun, as his father Yahya had been for Harun.
The Caliph took the unusual step of drawing up documents for each son to sign, promising to support the other and uphold his rights. Al-Mamun was to govern Khurasan while al-Amin was Caliph, but he was to inherit the Caliphate even if al-Amin’s sons were old enough to rule. The documents were signed in Mecca, while they were on pilgrimage in 802.
When they came home, the Caliph very suddenly ordered the execution of Jafar and the arrest of Yahya and Fadl. The Barmakid family was destroyed, overnight. Jafar’s body was cut up and nailed to three bridges.
The Caliph had probably become distant from the Barmakid family over time, though outsiders didn’t know this. A serious point of conflict was the family’s choices to be conciliatory with the Alids, the descendants of Ali. Fadl as governor of Khurasan had to deal with a rebellious Alid who lived in his territory. He got the man to agree to go live in Baghdad where the Caliph could watch him, and Jafar was appointed jailer. Jafar was a poor jailer, and the Alid family member was seen out in public. This could have felt, to the Caliph, like an early warning sign that the Barmakid family could use its money and Persian connections to set up a descendant of Ali in place of the Abbasids. Perhaps, given a bit more time, they would have tried.
There is also a story that Harun’s sister Abbasa was Jafar’s downfall. The deal was that they would never touch each other, but Abbasa secretly became pregnant and hid her child in Mecca. Someone in the harem, either Harun’s wife or some jealous slave girl, told her secret to Harun, who exploded in rage. If you look at Wikipedia, that is the story you will find to explain Jafar’s downfall, but apparently it is far from certain. Ibn Khaldun, the famous Muslim historian of the 14th century, doubted the story was true. At the end of it all, apparently we just don’t know anything for sure except that the Barmakids were destroyed and Jafar executed.
Jafar’s fallen reputation tarnished how he’s seen in later legends. In some of the Thousand Nights stories, he serves as a detective. But in the 1940 movie “The Thief of Baghdad,” he is an evil vizier who tries to usurp the throne by dark magic and take the princess. He has the same role in the video game “Prince of Persia,” and Disney’s Jafar character in its 1992 “Aladdin” is also an evil sorcerer threatening the throne and the princess. Maybe next the movies will discover that Jafar ibn Yahya al-Barmaki had a hand in building the first paper mill in Baghdad and he can star as the villain threatening the Lorax.