This paper analyses the incentives that shaped Hindu and Muslim interaction in India’s towns from the rise of Islam to the rise of European intervention in the 17th century; it argues that difierences in the degree to which medieval Hindus and Muslims could provide complementary, non-replicable services and a mechanism to share the gains from trade has resulted in a sustained legacy of religious tolerance. Due to Muslim-speciflc advantages in Indian Ocean shipping, incentives to trade across ethnic lines were strongest in medieval trading ports, leading to the development of institutions to support inter-religious exchange. Using new town-level data spanning India’s medieval and colonial history, this paper flnds that medieval trading ports were 25 percent less likely to experience a religious riot between 1850-1950, two centuries after Europeans eliminated Muslim advantages in overseas shipping. Medieval trading ports continued to exhibit fewer and less widespread religious violence during the Gujarat riots in 2002. The paper shows that these difierences are not the result of variation in geography, political histories, wealth, religious composition or of medieval port selection, and interprets these difierences as being transmitted via the persistence of institutions that emerged to support inter-religious medieval trade. The paper further characterises these institutions and the lessons they yield for reducing contemporary ethnic con∞ict.