Jāmi‘ al-Riyāsatayn Akşehirī Hasan Fahmi Efendi was born in 1796 in Ilgın, a district in Konya. He went to Konya to study at the important madrasas of the region and completed his education there. Madrasas in Konya were important centers of knowledge in central Anatolia. Therefore, prominent figures, such as Kara Halil Efendi (d. 1880), who became Shaykh al-Islam in 1877, came from Amasya to study in Konya and became Hasan Fahmi Efendi’s friend. After receiving the ijāza from Konya they went to Istanbul and took lessons from Vidinli Mustafa Efendi (d. 1855) in Fatih Mosque Madrasa. Other prominent figures such as Ahmed Cevdet Pasha (d. 1895) also attended the classes of Vidinli Mustafa Efendi in Fatih Mosque Madrasa, which was an important center of knowledge in this period in Istanbul.
Hasan Fahmi Efendi, after studying at the Fatih Mosque Madrasa, won first place in the test of ruūs and stepped into the Ottoman bureaucracy. Later, he taught at the Ayasofya Mosque Madrasa. In 1847, he became a professor at Fatḥ al-Ghāzī Madrasa with the degree of ibtidā-i khārij. It is understood that Hasan Fahmi Efendi started his scholarly career from the lower-level madrasas, since ibtidā-i khārij was a degree that was given to those who worked as professors at the khārij madrasa, which was the first step in the Ottoman madrasa system. Hasan Fahmi Efendi made progress in his teaching career in the madrasa system and reached Mūsila-i Sahn. Sahn-i Thamān madrasah were higher education and research institutions in the Ottoman madrasa system. He became a course agent (wakīl al-dars) in 1859 at the Department of Course (Wakālat al-Dars), which was established under the authority of the Shaykh al-Islām to organize education and training in the madrasas. In this position, he had an opportunity to get to know better how the institution of Shaykh al-Islām was functioning. Hasan Fahmi Efendi taught Abdulaziz, who was still the Crown Prince, teaching him the Arabic language, literature, and Islamic sciences. When Abdulaziz became the sultan, Hasan Fahmi Efendi’s fame increased due to his being the teacher of the sultan, and he received the title of mu‘allim-i sultānī (the teacher of the sultan). Apart from this title, he also received various orders, such as Order of the Majīdī (Mecīdī Nişanı) and Order of Othmani (Nişan-ı Osmani) in 1279-80.
Sultan Abdulaziz’s (r. 1861-1876) approach to governance was to assure conservative circles that he would not imitate the West, while also attempting to resolve the problems that the Empire faced. As a result of these efforts, Sultan Abdulaziz was closely observing important projects implemented in the fields of trade, industry, agriculture, roads and transportation in the province of Egypt, which was led by Kavalali Mehmet Ali Pasha and his sons. Sultan Abdulaziz, who intended to introduce similar reforms in other parts of the Empire, wanted to make a visit to observe the changes and introductions of Western technologies in the province firsthand. In addition, the Sultan intended to consolidate the Empire’s central domination over Egypt through his visit. Sultan Abdulaziz traveled from Alexandria to Cairo by train and on this journey he examined the railroads and trains with great interest and received information about them. The railroad, which had not become widespread in the Ottoman lands in those years, left a deep impression on the sultan and his delegation, and the visit to Egypt was instrumental in introducing a railway system to Istanbul. During his trip to Egypt, Sultan Abdulaziz’s teacher Hasan Fahmi Efendi also accompanied him. There he had a chance to exchange ideas with Ibrahim Ibn Ali al-Sakka, a prominent scholar of al-Azhar, who authored important works in tafsīr and hadīth, and al-Sakka was influenced by his scholarly depth.
Hasan Fahmi Efendi was later honored with the position of judgeship of Mecca and Istanbul, and fulfilled the responsibilities of professor, judge and muftī. Later, in 1867, he served as Anatolian and Rumelia Kazaskership (chief judge). After that, in 1868, he was appointed to the office of Shaykh al-Islāms, the highest rank of the Ottoman scholarly class, and remained in the position for three years until he was he was dismissed in 1871. He was reappointed for a second term in 1874, then later dismissed by the Sultan on 13 May 1876 and exiled to Medina after the Talaba-i Ulūm Uprising. He lived in Medina until his death in 1880 and was buried there.
Hasan Fahmi Efendi’s Shaykh al-Islāmship period coincided with a time of turmoil in the Ottoman Empire. Due to the introduction westernization and reforms, the powers of the office of Shaykh al-Islām were constantly restricted and its activities in the field of law and education were significantly reduced. As a result of these problems, Hasan Fahmi Efendi opposed the preparation of the Mecelle under the supervision of Ahmet Cevdet Pasha. The main factor that led to this opposition was not the idea of preparation a legal code, but preparation of the Mecelle under the roof of The Sublime Porte (Bāb-ı Ali) not the Office of Shaykh al-Islām (Bāb-ı Meşihat). Hasan Fahmi Efendi’s objected for two reasons. First, he believed that delegating the task to the Sublime Port would be a serious blow to the authority of the Shaykh al-Islām, who was already losing authority. Second, and more significant in my view, he believed that the preparation of the Mecelle was a scholarly task and that it was not appropriate for the bureaucratic office of The Sublime Porte. However, his efforts failed in the face of the rapidly developing nation-state and the dominant power of the institutions it created.
One of the important events that took place during Hasan Fahmi Efendi’s Shaykh al-Islāmship was Jamāl al-Dīn al-Afghānī’s visit to Istanbul. At the invitation of Sultan Abdulaziz al-Afghānī came to Istanbul in 1870 and attempted to influence the Ottoman establishment towards reform. One of these attempts was al-Afghānī’s participation in the opening sermon and giving a speech at the Dār al-Funūn, which was seen as an alternative to madrasa. This elicited a negative reaction from Hasan Fahmi Efendi. In addition, the proposals put forward by al-Afghānī in the direction of reform after his election as a member of the Board of Education (Majlis-i Ma‘ārif) and his ideas on various issues caused serious tensions between Hasan Fahmi Efendi and al-Afghānī. Finally, when al-Afghānī argued that Prophethood was just one craft among other crafts, Hasan Fahmi Efendi declared him an unbeliever because of this statement and provoked the people against al-Afghānī. He was supported in this by his course agent Halil Fevzi Efendi (d. 1884), who authored a treatise against Jamāl al-Dīn al-Afghānī entitled Suyūf al-ḳawāṭīʿ li-man qāla inna al-nubuwwat ṣanʿatun min al-ṣanāʾiʿ.
Hasan Fahmi Efendi authored a number of important works in Turkish, Arabic and Persian, especially in substantive law (fiqh), rational theology (kalām), Arabic literature and logic. Some of his writings were published in Istanbul in 1869 and 1876 as a lithograph under the title Majmū‘at al-rasā’il, along with other articles. Some of his works include:
1. Arabic Language and Rhetoric: Since Hasan Fahmi Efendi worked as a professor in high ranking madrasas in Istanbul and the lessons on Arabic language and rhetoric had an important place in the madrasa curriculum, he wrote many works in this fields to be used for teaching.
Riyād al-khāqāniyye. This work, written in the field of Arabic rhetoric and presented to Sultan Abdulaziz, consists of three chapters: Ma‘ānī, Bayān, and Badī‘.
Irshād al-mubtadī ʿalā al-Birgiwī. A commentary on al-ʿAwāmil, written by Muhammad al-Birgiwī in the field of Arabic grammar and taught as a standard textbook in the Ottoman madrasas.
al-Natā’ij al-sulṭāniyya. A study written in the field of waḍ‘ (semiology) and ādāb al-baḥth wa-al-munāẓara(dialectical inquiry), the two sciences that students studied after completing morphology and syntax in the madrasa curriculum.
Taʿlīqah ʿalā Sharḥ al-ʿIṣām ʿalā al-Risālat al-waḍʿiyya li al-Ījī. A treatise also on the science of semiology.
Risālat al-imtiḥān li al-ru’ūs. A study written in 1858 for the candidates for the test of ruūs at the request of Shaykh al-Islām Meşrepzāde Mehmed Ārif Efendi (d. 1858). In this work, he gathered different issues asked to students in exams from various disciplines from language, to the Qur’ānic exegesis, to law.
2. Logic: In the field of thee rational sciences, which had an important place in the madrasa curriculum, important works were written in the late Ottoman period. Shaykh al-Islām Hasan Fahmi Efendi contributed three works in the field of logic:
al-Qaṣīdah al-ʿAzīziyya. Hasan Fahmi Efendi presented this poem, which is referred to under different names in the library records, to Sultan Abdulaziz. The author later wrote a commentary on this work and named it Yusūfiyye in honor of Yusuf, the son of Sultan Abdulaziz.
Risālah fī al-manṭiq. This is another work written by Hasan Fahmi Efendi in the field of logic. The difference between this and the previous one is that it is written in prose.
Ḥāshiyah ʿalā ams̱ilat al-Durr al-nājī. Athīr al‐Dīn al‐Mufaḍḍal Ibn ʿUmar al‐Abharī’s (d. 1265) Isāghūjī fi al-Manṭiq written in the science of logic, was recognized as a vital textbook in the madrasa curriculum since the day it was written. On this book, Seyyid Ömer Ibn Salih Feyzi Tokadi (d. 1849) wrote a commentary titled al-Durr al-nājī and Hasan Fahmi Efendi wrote a glossary on Tokadi’s commentary.
3. Rational Theology: A final field to which Hasan Fahmi Efendi contributed important written works is theology. During his lifetime, reform and westernization efforts, and debates concerning societal changes, prompted scholars of the period to write works on issues related to theology. In this context, Hasan Fahmi Efendi wrote books and treatises on theological issues, including:
Ḥāshiyah ʿalā Sharḥ al-ʿAqāʾid. A glossary on the famous book of al-Taftāzānī (d. 1390), Sharḥ al-ʿAqāʾid, which shows that Sharḥ al-ʿAqāʾid was both included in the madrasa curriculum in this period and that new studies continued to be written about it until the last period of the Ottoman Empire.
Taʿliqa. Hasan Fahmi Efendi also wrote a gloss on ‘Abd al-Ḥakīm al-Siyalkutī’s (d. 1657) Ḥāshiyah ʿalā Sharḥ al-ʿAqāʾid.
al-Risālah fī kayfiyyat īmān Firʿawn. It was penned to defend the contentious view of Muḥy al-Dīn Ibn ‘Arabī (d. 1240) about the faith of Pharaoh.
 Jāmi‘ al-Riyāsatayn is the title given to individuals who were both the Sultan’s teacher and held the position of the Shaykh al-Islām.
 Ahmad Rafīq, Ilmiye Sālnāmesi (Istanbul: Matbaay-i ‘Āmire, 1334), pp. 599-600.
 Ruūs was the name given to the state office where bureaucratic procedures for appointments were made.
 In the Ottoman education system, the Sahn-ı Semān (eight courtyards), which consists of eight madrasah within the Fatih Complex, is the name given to the first stage of the madrasa degree.
 Bursali Muhammad Tāhir, Osmanlı Muellifleri (Istanbul: Matbaay-i ‘Āmire, 1333), 1: 216; Ahmad Rafīq, Ilmiye Sālnāmesi, p. 600.
 The name of a military and civilian order of the Ottoman Empire. The Order was awarded by the Sultan as a reward for distinguished service to the Empire.
 The second highest order in the Ottoman Empire. It was awarded by the Sultan to Ottoman civil servants and military leaders for outstanding servicesto the Empire.
 Mehmet Aykanat, “Bir Osmanlı Hukuk Adamı Ilgınlı Şeyhülislam Hasan Fahmi Efendi”, Selçuk Üniversitesi Hukuk Fakültesi Dergisi, 2018/26-1, p. 50.
 Bursali Muhammad Tāhir, Osmanlı Muellifleri, 1: 216; Ali Kemali Aksüt, Sultan Aziz’in Mısır ve Avrupa Seyahati (İstanbul: Ahmet Sait Oğlu Kitabevi, 1944).
 The Talaba-i Ulūm Uprising refers to events that took place in the late 1800s produced by the conflict of interest between some politicians and bureaucrats. Madrasa students in Istanbul were incited to rebel against the administration and these students poured into the streets. Students who performed street demonstrations from time to time gathered at the Fatih square as a group of ten thousand people and chanted slogans against the government. Students demanded that the grand vizier and Shaykh al-Islām be dismissed resulting in Shaykh al-Islām Hasan Fahmi Efendi’s dismissal in May 1876. See İlter Turan, “Osmanlı İmparatorluğunun Son Döneminde Öğrenci Siyasal Faaliyeti”, İstanbul Üniversitesi İktisat Fakültesi Mecmuası, 1969/29, pp. 175-178.
 Ahmad Rafīq, Ilmiye Sālnāmesi, p. 600; Abdülkadir Altunsu, Osmanlı Şeyhülislāmları (Ankara: Ayyıldız Matbaası, 1972), pp. 200-201.
 Mehmet İpşirli, İlyas Çelebi, “Hasan Fahmi Efendi”, Diyanet Turkish Encyclopedia of Islam (İstanbul, 1997), pp. 16: 320-322.
 Marmara Üniversitesi İlahiyat Fakültesi Library, Gnl., No: 1298.
 Some of these works were printed and some are still manuscripts. For detailed information about his works see Bursali Muhammad Tāhir, Osmanlı Muellifleri, 1: 216; Ahmad Rafīq, Ilmiye Sālnāmesi, p. 601.