This essay explores the interlocking roles of science and religion in Sino-Western exchanges by examining China's encounter with Jesuit mathematics in the seventeenth and eighteenth centuries. It first focuses on late Ming by studying the joint translation of Euclidean geometry by high-ranking scholar-official Xu Guangqi (1562–1633) and Italian Jesuit Matteo Ricci (1552–1610). Then it studies how this encounter affected later literati-scholars, with a special attention to Mei Wending (1633–1721), the leading mathematical astronomer of early Qing. I argue that Xu's appropriation of Western mathematics not only helped strengthen the basis of Confucian statecraft in the milieu of late Ming crisis but also contributed to later reconstruction and renaissance of Chinese classical tradition through Qing-dynasty evidential studies. Far from predetermined, this cross-cultural encounter represents a trial-and-error process of contested accommodation dictated by different personal agendas, changing socio-political circumstances, evolving intellectual trends as well as shifting global balance of power.