In 1005, Beruni came back to his motherland Khoresm. In 1010, the ruler of Khoresm Abul Abbas Ma’mun II gave orders to bring the scholar Beruni to Urgench, the capital city of Khoresm because he had good respect to Beruni as an appreciated teacher. In his turn, Beruni described the positive qualities of the ruler Abu-l-Abbas Ma’mun II in his book “Famous People of Khoresm”. Abu-l-Abbas Ma’mun II was the son of the former ruler Ma’mun I and the third generation of the Caliphate of the Abbasids. He followed his grandfather Kharun ar-Rashid’s ruling principles, supported the science and education in the country and founded the Academy of Sciences in Khoresm. This Academy of Sciences gathered most of the famous scholars of that time as Abu Sahl al-Masihi, Abu Nasr ibn Iraq, doctor Abu-l-Hasan Hammar, a famous historian Ibn Miskavayh (died in 1030), Abu Ali Ibn Sina (Avicenna), Abu Rayhan al-Beruni and others. Beruni was a respectable official in the Royal Court of Ma’mun II. Making use of his high position in the court, he had an access to the storehouse of precious metals where he carried scientific investigations on them. As a result of these endeavours, there appeared his famous book on mineralogy “Kitab al-Jamahir fi ma’rifat al-javahir” (A Collection of Informa-lion on Precious Metals).
Beruni lived for seven years at the court of Ma’mun II. At the Academy of Ma’mun II, he collaborated his searches with a worldfamous scientist of his time Abu Ali Ibn Sina (Avicenna) and had heated debates and discussions with him on different proble ms of science and education. Some of his writings with Ibn Sina (Avicenna) have reached us. In 1017, an Arabian invader Mahmud Ghaznavi began his raid to Khoresm. The ruler Ma’mun II gathered all the members of the Royal Court, the scholars of the Academy of Sciences and announced that anyone who wished to stay in the service of the invader Mahmud Ghaznavi could stay in the Academy, and if there was anyone who wished to leave Khoresm, he was allowed to do so. Some of the elite of the court decided to leave the court and among them was Ibn Sina (Avicenna). Getting use of the political condition in the country in 1017, the opponent parties organized a plot against Ma’mun II and killed him. After the death of Ma’mun II, al-Beruni was taken to Ghazni together with the others as a prisoner. It was a dangerous situation for Beruni. According to the order issued by Mahmud Ghaznavi, Beruni and Abdussamad Awal were to be killed because they were in the list of more devoted members of the court of Ma’mun II. Thanks to the support made by the Vizier of Mahmud Ghaznavi Khoja Hasan, al-Beruni remained alive. From 1017 to 1030, Beruni lived a dangerous and risky life under the control of Mahmud Ghaznavi. In all his military marches, Mahmud Ghaznavi would take him with himself as an astrologist. Beruni was several times sentenced to death or put into prison and he was made to live under the conditions dictated by Mahmud Ghaznavi. Even in the Royal Court of Mahmud Ghaznavi, Beruni did not stop his researches. Making use of the materials he had collected during the march to India accompanying Mahmud Ghaznavi, Beruni wrote his book “India” (Definition of the Essence of Teachings of Indians).
In 1030, Mahmud Ghaznavi died and, according to his will, his younger son Muhammad sat on the throne. However, his elder son Mas’ud overturned his brother after some months and occupied the throne (1030-1041). During the reign of Mas’ud, Beruni had normal conditions of life because the prince Mas’ud was very keen on the scholar Beruni. He had good respect for him because he used to learn from him the secrets of astronomy and other sciences as well as the Arabic language. In accord with the orders of the ruler Mas’ud, Beruni had suitable conditions for his scientific career, and he was given gifts and support from the ruler.
Thankful for the support and care taken from the ruler Mas’ud, Beruni wrote his book “The Laws of Mas’ud” devoted to him. In the preface of the book, al-Beruni wrote about the ruler Mas’ud the following lines: “He kindly provided me with suitable conditions for my researches, supported me in all cases and showed great respect for me”. This book was an excellent and the most readable source on astronomy and mathe matics, and was highly appreciated by the experts of that time.
We have the following information at our disposal about the students and followers of Beruni. First of all, the ruler of Khoresm Abu-l-Abbas Ma’mun II ibn Ma’mun put himself very close to the personality of Beruni and considered himself to be his student because sometimes he used to take lessons from Beruni on different problems of knowledge and science. There were some of Beruni’s students at the court of Qabus ibn Vashmgir as well but their names did not reach us. Even Mahmud Ghaznavi sometimes addressed him as his teacher. His elder son Mas’ud accepted Beruni as a great master and teacher and showed much support for the scholar. Beruni and Ibn Sina (Avicenna) were in good and friendly relations with each other and considered themselves to be “masters and students” as they often shared opinions and gave advice to each other. Their writings and letters to each other, 18 in number, have reached us. The content of these writings prove that these two geniuses respected each other.