publication-status: Publishedtypes: ArticleThis article examines the career and ideas of a late Mughal administrator, a Shi‘a Muslim called Ali Ibrahim Khan, who was appointed magistrate of the north Indian city of Banaras after its conquest by the East India Company in 1781, and remained in that position until his death in 1792. Engaging with recent research on legal pluralism on the one hand, and on legal and cultural intermediaries on the other, this paper examines the imagination of imperial, religious and legal spaces by this prolific historian, poet and legal ethnographer, an under-studied protagonist of the process of transition to colonialism in India. Using a range of Persian-language manuscript sources in addition to archival and published material in Urdu and English, the article reveals the principles of Ali Ibrahim Khan's pragmatic but principled efforts to reconcile recognisably Islamic legal principles and procedures with the demands of the emerging colonial situation, and his systematic reference to locality and custom in order to do so