For the consolidation of his empire, it was realized by Mammon, the Abbasid king, that it was necessary to win the sympathy and support of the Iranians who had always been friendly to the Ahlul Bayt. Consequently , Mammon was forced , from a political point of view , to establish contacts with the tribe of Banu Fatimah at the expense of the ties with Bani Abbas and thereby win the favour of the Shi’a . Accordingly, he declared Imam Ali ar- Rida as his heir even anaginst the Imam’s will and got his sister Umm Habibah marrried to him. Mammon expected that Imam Ali ar-Rida would lend him his support in political affairs of the State.
But when he discovered that the Imam was little interested in political matters and that the masses were more and more submitting them to him due to his spiritual greatness, he got him poisoned.
Yet the exigency which directed him to nominate Imam Ali ar- Rida as his heir and successor still continued. Hence he desired to marry his daughter Ummul-Fadl to Muhammad al -Javad, the son of Imam Ali ar- Rida and with this object in view, he summoned the Imam from Medina to Iraq. The Bani Abbas were extremely disconcerted when they came to know that Mammon was planning to marry his daughter to Imam Muhammad al -Javad.
A delegation of some leading persons waited on him in order to dissuade him from his intention. But continued to admire the learning and excellence of the Imam. He would say that though Imam Muhammad al - Javad was still young, yet he was a true successor to his father in all his virtues and that the profoundest scholars of the Islamic world could not compete with him. When the Abbasids noticed that Mammon attributed the Imam’s superiority to his learning they chose Yahya iba Aktham, the greatest scholar and jurist of Baghdad , to contend with him. Mammon issued a proclamation and organized a grand meeting for the contest which resulted in a huge gathering of people from all parts of the kingdom. Apart from noble and high officials, there were as many as nine hundred chairs reserved for scholars and learned men only. The world wondered how a young child could contest with the veteran judge in religious laws ( qadi ‘l - qudat ) and the greatest scholar of Iraq. Imam Muhammad al -Javad was seated beside Mammon on his throne face to face with Yahya ibn Aktham , who addressed the Imam thus: `Do you permit me to ask you a question ?’’ `Ask me whatever you wish,’’said the Imam in the typical tone of his ancestors.
Yahya then asked the Imam, `what is your verdict about a man who indulges in hunting while he is in the state of ihram.’’ (In the code of religious law hunting is supposed to be forbidden for a pilgrim). The Imam at once replied, `your question is vague and misleading. You should have definitely mentioned whether he hunted within the jurisdiction of the Kaba or outside ; whether he was literate or illiterate ; whether he was a slave or free citizen ; whether he was a minor or a major ; whether it was for the first time or he had done it previously ; also whether, that victim was a bird or some other creature ; whether the prey was small or big ; whether he hunted in the day or at night ; whether the hunter repented for his action or persisted in it ; whether he hunted secretly or openly ; whether the ihram was for `umrah or for hajj .
Unless all these points are explained no specific answer can be given to this question.’’ al - Qadi Yahya was staggered in listening to these words of the Imam and the entire gathering was dumbfounded.
There was no limit to al - Mammon’s pleasure. He expressed his sentiments of joy and admiration thus, `Bravo! Well done! O Abu Jafar!(Ahsanta,ahsanta ya Aba Jafar),your learning and attainments are beyond all praises .’’ As Mammon wanted the Imam’s opponent to be fully exposed, he said to the Imam, `You may also put some question to Yahya ibn Aktham .’’ Then Yahya also reluctantly said to the Imam, `Yes, you may ask me some question. If I know the answer, I will tell you; otherwise, I shall request you to give answer.’’ Thereupon, the Imam asked a question to which Yahya could not reply.
Eventually, the Imam answered his question. Then Mammon addressed the audience thus: `did I not say that the Imam comes of a family which has been chosen by Allah as the repository of knowledge and learning? Is there any one in the world who can match even the children of this family?
’’All of them shouted, `Undoubtedly there is no one parallel to Muhammad ibn `Ali al-Javad.’’ In the same assembly Mammon wedded his daughter Ummu‘l - Fadl to the Imam and liberally distributed charity and gifts among his subjects as a mark of rejoicing. One year after his marriage the Imam returned to Medina from Baghdad with his wife and there he set about preaching the Commandments of Allah.