We aimed to estimate the occurrence of syphilis in pregnant women (SPW) and congenital syphilis (CS) in the municipalities of the state of São Paulo (SP) and evaluate their relationship with socioeconomic, demographic, and health care variables. We developed an ecological study based on secondary data of SPW and CS with spatial and temporal components from 645 municipalities in SP and included data from 2007 to 2018. We modeled the data in a Bayesian context, considered spatial and temporal random effects, and used a binomial negative probability distribution. We found a continuous increase in the relative temporal risk of SPW, from 2007 to 2018, and CS, from 2007 to 2017, when their incidences increased by 8.7 and 6.6 times, respectively. Moreover, this increase occurred in en bloc in practically all municipalities of SP. The increase in SPW was associated with teenage pregnancy, municipalities with a large number of inhabitants, and aids incidence. The increase in CS was associated with municipalities with a large number of inhabitants, incomplete antenatal care, inadequate technology to perform deliveries in the municipality, and aids incidence. Interventions to control these diseases are needed in almost all the municipalities of the SP.