Introduction: Intimate domestic violence causes psychological consequences in pregnancy and maternal competency. We aimed to assess the effect of domestic violence on mental health and maternal competency with the moderating role of mother-infant attachment behavior. Methods: This prospective longitudinal study was conducted on 254 primiparous mothers in the third trimester of pregnancy referring to selected health centers in Qazvin province, Iran. Data collection tools were questionnaires. Data were analyzed by SPSS and Smart Partial Lease Square3 software. Results: The results of the structural equations model showed that domestic violence has a positive and significant effect on mental health disorders (β = 0.87). Mental health disorder has a negative and significant effect on parental acceptance (β = -0.55). Domestic violence has a negative and significant effect on mother-infant attachment behavior (β = -0.83), also mother-infant attachment behavior is a moderator of the relationship between pregnancy violence and maternal competency (T-value = 3.17). Conclusion: The results revealed that domestic violence during pregnancy affects the mental health of pregnant mothers and maternal competency and mother-infant attachment behavior moderates this relationship. Therefore, it is recommended that mothers facing domestic violence be identified and receive psychological support and counseling, and also improve maternal competence and mother-infant attachment behavior in mothers exposed to violence.