Few accounts exist of programmes in low- and middle-income countries seeking to strengthen community knowledge and skills in mental health. This case study uses a realist lens to explore how a mental health project in a context with few mental health services, strengthened community mental health competence by increasing community knowledge, creating safer social spaces and engaging partnerships for action. We used predominantly qualitative methods to explore relationships between context, interventions, mechanisms and outcomes in the "natural setting" of a community-based mental health project in Dehradun district, Uttarakhand, North India. Qualitative data came from focus group discussions, participant observation and document reviews of community teams' monthly reports on changes in behaviour, attitudes and relationships among stakeholder groups. Data analysis initially involved thematic analysis of three domains: knowledge, safe social spaces and partnerships for action. By exploring patterns within the identified themes for each domain, we were able to infer the mechanisms and contextual elements contributing to observed outcomes. Community knowledge was effectively increased by allowing communities to absorb new understanding into pre-existing social and cultural constructs. Non-hierarchical informal community conversations allowed "organic" integration of unfamiliar biomedical knowledge into local explanatory frameworks. People with psycho-social disability and caregivers found increased social support and inclusion by participating in groups. Building skills in respectful communication through role plays and reflexive discussion increased the receptivity of social environments to people with psycho-social disabilities participation, thereby creating safe social spaces. Facilitating social networks through groups increases women's capacity for collective action to promote mental health. In summary, locally appropriate methods contribute most to learning, stigma reduction and help-seeking. The complex social change progress was patchy and often slow. This study demonstrates a participatory, iterative, reflexive project design which is generating evidence indicating substantial improvements in community mental health competence.