The study is focused on the relation between theology and mathematics in the situation of increasing secularization. My main concern in the second part of this paper is the early-twentieth-century foundational crisis of mathematics. The hypothesis that pure mathematics partially fulfilled the functions of theology at that time is tested on the views of the leading figures of the three main foundationalist programs: Russell, Hilbert and Brouwer.