The aim of this study is to analyze the spatiotemporal risk of congenital syphilis (CS) in high-prevalence areas in the city of São Paulo, SP, Brazil, and to evaluate its relationship with socioeconomic, demographic, and environmental variables. An ecological study was conducted based on secondary CS data with spatiotemporal components collected from 310 areas between 2010 and 2016. The data were modeled in a Bayesian context using the integrated nested Laplace approximation (INLA) method. Risk maps showed an increasing CS trend over time and highlighted the areas that presented the highest and lowest risk in each year. The model showed that the factors positively associated with a higher risk of CS were the Gini index and the proportion of women aged 18–24 years without education or with incomplete primary education, while the factors negatively associated were the proportion of women of childbearing age and the mean per capita income.