Violence is a major social problem in Brazil, with severe repercussions on the health care sector. Primary health care professionals, especially community health workers (CHWs), are at high risk of violence at facilities and in the socially vulnerable area where they work. This study analyzed the relationships between adverse working conditions and dimensions of localized violence on the prevalence of common mental disorders (CMD) among CHWs in Fortaleza, a state capital in Northeastern Brazil. Information was collected with a self-report questionnaire containing items on sociodemographic data, work-related violence, psychoemotional signs and symptoms (Self-Reporting Questionnaire-20), mental health care, and absence from work due to general or mental health issues. Based on the responses of 1,437 CHWs, the prevalence of CMD (32.75%) was associated with perceived, witnessed, or suffered violence in the work area. In the hierarchical analysis, CMD were associated with age, sex, religious identity, years of experience as a CHW with the Family Health Strategy (FHS), work neighborhood, activities in the community, considering the lack of bonding with families as an obstacle, having suffered domestic violence, use of medication for emotional dysregulation, identifying the neighborhood as violent, considering violence a physical or mental health determinant, and identifying impunity as a cause of violence. Thus, the work and mental health of CHWs were significantly affected by violence dimensions. Our findings are relevant to the adoption of strategies to mitigate the effects of violence on the work and mental health of CHWs.