Imam played a significant role in the educating of Muslims. Setting examples of education through one's own conduct.
He saw a short period of the rule of Harun Rashid who had murdered his father. Harun Rashid also attempted to kill Imam Ali Raza (a.s.) but was unsuccessful. After Harun's death, his sons, Amin and Mamun fought for power. Mamun won with Amin being killed.
Immediately after becoming the Khalifa Mamun, according to the tradition started by Muawiya, had to name a successor (heir apparent) . Mamun summoned Imam to come to his capital Marw sending a messenger to Medina to bring the Imam to him and specifying a certain route and sending a security force . The route he chose was not the normal route where, a lot of Shia's lived. On the way they entered a town called Nishapur. There the scholars and people requested Imam to tell them a hadith. Imam related the following hadith which is known as the hadith of the golden chain.
"My father Musa Al-Kadhim narrated to me from his father Ja'fer As-Sadiq from his father Mohammed Al-Baqir from his father Ali Zaynul Abedeen from his father , the martyr of Kerbala from his father Ali ibn Abu Talib saying :"My loved one, and the pleasure of my eyes, the Messenger of God (S.A.W.) told me once, that Jibrail told him from the Lord "The kalima of LA ILAHA ILLALLAH is my fort; whoever said it would enter my fort; and whoever entered my fort was safe from my punishment".
Those who wrote down the hadith numbered twenty thousand. People started reciting the Kalima when Imam put his hand up and continued: "Yes, the kalima is Allah's fort. It will provide you with excellent safety but on one condition only and that is that you obey and follow us - the holy Imams in the progeny of the holy Prophet (S.A.W.). On reaching Marw Mamun forced Imam to accept the heir apparency (To be the leader after him). Imam accepted unwillingly.
Why did Mamun want Imam to be the heir apparent ?
1. To please the Shia public opinion in Khurasan and the surrounding areas which would make it easier for Mamun to be accepted by the people there and a victory over his brother Amin.
2. To avoid clashes with those like the Alawids who had always threatened the Abbasids with various uprisings.
Mamun celebrated the occasion of Imam's acceptance of heir apparency. Imam only gave a short sermon saying after he had praised Allah "We have over you a right appointed by the Prophet, and you have a right over us as well; so if you fulfil your duty towards us, we will be bound to perform our duty towards you".
Mamun ordered a new coin to be minted with Imam Ar-Raza's name on it. Imam however knew that this would not last long.
Soon Mamun put Imam under constant watch. Imam used the position to spread the true word of Islam. Mamun's court was visited by thousands and Imam made an impact on their minds. His ahadith were widely recorded. Mamun who was fond of scholarly discussions would arrange for intellectuals from Greece, Italy , India etc. to come to his court and hold discussions with the Imam.
One day a Jewish scholar was brought by Mamun to debate with Imam. The scholar asked: "How can you accept Muhammad to be the prophet of God when he showed no miracles ? "
Imam replied : "The greatest of miracles of Allah is the human mind. It allows ideas to be thought through and reasoned out. Islam appeals to human reason. Man must accept God through reason and not through miracles ".
The scholar did not have much to say after that answer.
Imam also encouraged greatly the remembrance of Imam Husayn (a.s.)
Mamun was never sincere in his behaviour towards Imam. Seeing the Imam's popularity increase disturbed him immensely especially after the occasion when he requested Imam to lead Eid prayers as he was not well. He saw that even before Imam had reached the mosque the people had lined the streets and were reciting takbir and it seemed that even the walls of Marw were doing the same. He had to ask Imam to go back that day.
There are various accounts of how Imam Ali Ar-Raza (a.s.) was killed by Mamun. One of them is that Imam used to like grapes and Mamun offered Imam poisoned grapes. Imam was ill and died after two days on the 29th Safar 203 a.h.
Imam Ali Ar-Raza (a.s.) died in Toos in a village called Sanabad. He had only one son, Imam Muhammad At-Taqi (a.s.), who succeeded him as the 9th Imam.
Mamun ordered Imam's grave to be dug near his father Harun's and when it was being dug he said that Imam had told him that when his grave would be dug water and fish would appear underneath. Just as Imam had said when they finished digging a spring of water appeared with fish in it and then disappeared. Imam is buried there at what is today called Mashhad in IRAN.