The heterodox nature of his religious beliefs and those of his vazir, Hajjl Mirza Aqasi, did not provide for even a theoretical acknowledgment of the Shah's submission to a marja'-i taqlld. Although the Babi insurrections might have been expected to bring together ulama and monarchy against a common enemy, they revealed themselves ultimately as events of passing and marginal importance, despite their violent and spectacular appearance. In the reign of Nasir ud-Din Shah, intermittent attempts were again made to restore some kind of viable relationship between the ulama and the state, but in vain: to the inherent incompatibility between Shi'i doctrine and monarchy had been added an intense and specific hatred of the Qajar dynasty. Certain aspects of Fath 'All Shah's clerical policy may again be discerned in the events of Muhammad Shah's reign. He, too, as a sign of piety, extended his patronage to the shrines of Arab Iraq: he had the golden dome at Karbala restored after its destruction by the WahhabI raiders in 1216/1801,1 and in 1252/1836-1837, sent Mirza Hasan Rashti to supervise repairs undertaken on his orders at Ka?imayn.2 Mosques were again built in the name of the sovereign, notably the Masjid-i Jami' in Khuy. Early in his reign he entrusted the distribution of the royal bounty among the ulama and sayyids to Mirza Nasrullah Ardablll, and the sum given away yearly amounted to 100,000 tomans. Hajj Mulla Muhammad Ja'far Astarabadi, first invited to settle in Tehran by Fath 'Ali Shah, was in 1255/1839-1840 again summoned to the capital by Muhammad Shah.' On occasion, clerical intercession on behalf of rebels was accepted; thus the ulama of Shushtar obtained pardon for Muhammad TaqI Khan, a rebellious Bakhtiyarl chieftain.6 One of the ulama, Hajj Mulla Ahmad Kirmanshahi, was even appointed governor of Dizful.7 While Fath 'Ali Shah, for all his show of piety, had not prohibited the sale of alcohol, his successor did so, and was himself an abstainer. He directed, moreover, that all lands seized by Nadir Shah should be restored to their original owners, if proof of ownership could be provided to a shar' court. Considering the length of time that had elapsed since the death of Nadir, it seems probable this measure was intended to lessen the enmity of the ulama: clearly Fath 'All Shah had never found it necessary. Whether it was any longer possible to determine the ownership of the confiscated lands, seems in any event questionable.
Such expressions of orthodox piety and deference to the ulama appear, however, as isolated elements in contradiction to the general tendencies of their reign—partly as habits inherited from Fath 'Ali Shäh, and partly as unimportant and incidental concessions. Muhammad Shah's devotion to Sufism, and more particularly to the eccentric person of his preceptor and vazlr, IJäjjl Mirzä Äqäsi, tended to override other loyalties. In the ancient conflict between Sufi and faqih, the monarch was now involved; and the precarious balance between the monarchy and the ulama preserved by Fath 'Ali Shäh was virtually destroyed. Muhammad Shäh appears to have been inclined from his earliest youth to seek the company of dervishes, and his acquaintance with Häjji Mirzä Äqäsi confirmed these early tendencies. One of the Ni'matullähl order, Muhammad Ridä Hamadänl ("Kauthar 'Ali Shäh"), had taken refuge with 'Abbäs Mirzä from the persecutions of the ulama and was an honored figure at the Crown Prince's court.10 It is reasonable to suppose that Muhammad Shäh came under his influence while in Tabriz. Not only Häjji Mirzä Aqäsi, but also a certain Pir Häjji 'Abd ul-Vahhäb Nä'ini prophesied that among all the Qajar princes, Muhammad would succeed to the throne. While Häjji Mirzä Äqäsi was rewarded with the control of Iran, Pir Häjji 'Abd ul-Vahhäb received a more modest token of gratitude in the shape of a shrine erected for him in Nä'in.
It was, however, Häjji Mirzä Äqäsi who ultimately gained the devotion of Muhammad Shäh. Born in Erivan, he was taken in his youth by his father, Mirzä Muslim to the 'atabät, where he studied under the celebrated Sufi, 'Abd us-Samad Hamadänl.12 When his master was killed in the Wahhäbi attack on Karbala, Häjji Mirzä Äqäsi left the 'atabät, and for some time worked as clerk to the Armenian patriarch of Erivan.13 After further wanderings in the guise of a dervish, he joined the court of 'Abbäs Mirzä in Tabriz, where he established himself as tutor and companion to Muhammad Mlrza.
According to the Nasikh ut-Tavarikh, Muhammad Shah considered Hajjl Mlrza Aqasi to be "the pole of the firmament of both sharl'at and tariqat," and was strengthened in his conviction by the wondrous deeds which Hajjl Mlrza Aqasi performed.15 Thus he was reputed to have once alleviated the ferocity of the summer heat for the sake of the Shah's well-being.16 It would seem that the relation between the monarch and his minister was even more than of disciple and spiritual guide. Muhammad Shah "did not doubt that . . . Hajjl Mlrza Aqasi had direct and frequent communications with the divinity, and that he was himself a being of far from ordinary nature." After the disgrace of Qa'im Maqam early in the reign of Muhammad Shah (1251/1836), the affairs of Iran were controlled until 1848 by this dervish of whom an English observer remarked that "his words and actions are strongly tinctured with real or affected insanity." Amidst the eccentricity of his rule, however, one constant element is visible: patronage of Sufis and their shrines. Whereas Fath 'All Shah lavished his attentions on the shrines of Qum, Mashhad, and Arab Iraq, Muhammad Shah, guided by Hajjl Mlrza Aqasi, preferred to attend to the tombs of Farld udDln 'Attar and Shaykh Mahmud Shabistarl.19 Other places of Sufi pilgrimage were erected or repaired in Kirman,20 Na'in, Bistam,21 and Turbat-i Shaykh Jam. A number of lands round Kirman were assigned as vaqf to the shrine of Shah Ni'matullah Vali in Mahan.23 Sufis were given posts at court and entrusted with government missions: Mlrza Mihdi Khu'I, a murshid (spiritual guide) of the Ni'matullahl order, was chief scribe to the Shah; a dervish, 'Abd ul-Muhammad Mahallati, was once dispatched to Herat to negotiate with the Amir.