To estimate the prevalence of syphilis and its associated factors in women who were treated at public maternity hospitals and received prenatal care in a primary healthcare unit. This cross-sectional study included 399 postpartum women. Interviews were conducted, and additional data were extracted from the pregnant woman's booklet, medical records, and printed tests. The dependent variable was a gestational syphilis diagnosis. The independent variables were grouped into socioeconomic and demographic, behavioral, reproductive, and prenatal blocks. The prevalence, prevalence ratios, and 95% confidence intervals (95%CI) were calculated. The χ 2 test was also performed (p≤0.05). Multivariate analysis was performed using Poisson regression models. The prevalence of gestational syphilis was 9.61% (95%CI: 7.14-12.83). We identified the following determining factors (adjusted prevalence ratios): history of sexually transmitted infections (2.3), first sexual intercourse by the age of 15 (2.42), partner having a history of syphilis (5.98), partner using crack/cocaine (6.42) and marijuana and others (3.02), not having a partner (3.07), low income (2.85), history of stillbirth (5.21), beginning prenatal care in the third trimester (3.15), and prenatal care received in a primary healthcare unit (without a Family Health Strategy team) (0.35). Individual and prenatal factors were associated with gestational syphilis. To control congenital syphilis, targeted interventions are needed to control syphilis in the adult population including expansion of access to quality prenatal care with identification of risks for syphilis and connection between prevention and treatment actions, implementation of strategies focused on early sexual education, effective establish prenatal care involving both partners, and effective implementation of the National Men's Health Policy (PNAISH - Política Nacional de Atenção Integral à Saúde dos Homens ).