Many of the risk factors for violence against children are particularly prevalent in families and communities affected by HIV/AIDS. Yet, in sub-Saharan Africa, where HIV rates are high, efforts to prevent or address violence against children and its long-lasting effects are hampered by a lack of evidence. We assessed the relationship between violence exposure and mental health among HIV-affected children attending community-based organisations in South Africa (n = 834) and Malawi (n = 155, total sample n = 989) at baseline and 12-15-month follow-up. Exposure to violence in the home and in the community was high. HIV-negative children who lived with an HIV-positive person experienced most violence overall, followed by HIV-positive children. Children unaffected by HIV experienced least violence (all p < .05). Interpersonal violence in the home predicted child depression (beta = 0.17, p < .001), trauma symptoms (beta = 0.17, p < .001), lower self-esteem (beta = -0.17, p < .001), and internalising and externalising behavioural problems (beta = 0.07, p < .05), while exposure to community violence predicted trauma symptoms (beta = 0.16, p < .001) and behavioural problems (beta = 0.07, p < .05). Harsh physical discipline predicted lower self-esteem (beta = -0.18, p < .001) and behavioural problems for children (beta = 0.24, p < .001). Exposure to home (OR: 1.89, 95% CI: 1.23-2.85) and community violence predicted risk behaviour (OR: 2.39, 95% CI: 1.57-3.62). Over time, there was a decrease in depressed mood and problem behaviours, and an increase in self-esteem for children experiencing different types of violence at baseline. This may have been due to ongoing participation in the community-based programme. These data highlight the burden of violence in these communities and possibilities for programmes to include violence prevention to improve psychosocial well-being in HIV-affected children.