The aim of this research was to evaluate the incidence of congenital syphilis and the ratio between congenital syphilis and syphilis in pregnant women in Brazil according to socioeconomic indicators (inadequate water supply and sanitation; illiteracy at 15 years of age or older; household income per capita; proportion of poor people; Gini index; human development index; and average health expenditure per inhabitant by the health system) and prenatal quality-of-care indicators. We conducted an ecological study using a sample composed of 257 municipalities, each with ≥ 100,000 inhabitants. Data was collected from four public databases: the Brazilian Institute of Geography and Statistics, comprising socioeconomical data from the 2010 census; and the data of 2019 available in the databases of the Department of Informatics of the Brazilian Health System, Information and Management of Primary Care, and the Electronic Citizen Information System. Descriptive analysis of dependent and independent variables and bivariate analysis by Negative Binomial regression were carried out. The mean incidence of congenital syphilis was 38% higher in municipalities with a Human Development Index up to 0.785 (ratio of means [RM] = 1.38; p = 0.049) and 57% higher among populations where less than 50% of primary healthcare services provided a rapid test for syphilis (RM = 1.57; p < 0.001). The ratio between congenital syphilis and syphilis in pregnant women was 29% higher in municipalities with a low household income per capita (RM = 1.29; p < 0.001) and 28% higher in locations where less than 50% of the primary healthcare services provided a rapid test for syphilis (RM = 1.28; p < 0.001). There was no statistical significance of the quality of prenatal care compared to the outcomes. This result underscores the challenges in detecting syphilis infections among pregnant women during prenatal care, consequently increasing the risk of vertical transmission of the disease to the fetus. Traits of inequality in the occurrence of congenital syphilis also draw attention to strategies to reduce health inequities and improve prenatal care.