Overweight and obesity are on the rise worldwide and may affect female sexual function. The aim of this study was to investigate the relationship between sexual function in normal and overweight pregnant women with gestational diabetes mellitus (GDM). This cross-sectional study was conducted in overweight and normal-weight pregnant women with GDM in Sari, Iran. Data were collected from 2018 to 2021. The demographic data collected from the participants included age, educational level, occupation, gestational age, duration of marriage, number of births, place of residence (city or village), private house, private bedroom, and insurance status. The General Health Questionnaire, Female Sexual Function Index (FSFI), and Enriched Marital Satisfaction questionnaires were used to assess mental health, sexual functioning, and marital satisfaction, respectively. The study included 200 women with GDM. The mean age of the participants was 29.75 (SD = 4.40) years. Among pregnant women with GDM, 56.50% of them had sexual dysfunction based on FSFI. The mean FSFI score in pregnant women with GDM was 25.60 (SD = 3.61). Among the participants, 50.00% had normal body mass index (BMI). There was no significant difference between BMI status and total sexual function score (p > 0.05). The multivariate analysis revealed that marital satisfaction (β = 0.41, p < 0.001) and BMI status (β = -0.15, p = 0.002) were the only factors significantly associated with overall sexual function, explaining 27% of the variance in the total FSFI score. The results of this study showed that there was no significant relationship between sexual dysfunction and obesity in GDM. Considering that the research in this area is very limited and the negative effects of obesity and GDM have been confirmed in many areas, including sexual desire disorder, necessary planning should be done to control these factors.