There is a lack of mental health promotion and treatment services targeting HIV-positive men who have sex with men (HIVMSM) in China. The aim of this study was to evaluate the mental health promotion efficacy of an online intervention that combined Three Good Things (TGT) with electronic social networking (TGT-SN) and an intervention that used TGT only (TGT-only), compared with a control group. We conducted a randomised controlled trial among HIVMSM in Chengdu, China. The participants were randomly assigned to the TGT-SN, TGT-only, and control groups. The participants in the TGT-SN group were divided into five social network groups and asked to post brief messages to the group about three good things that they had experienced and for which they felt grateful. The participants in the TGT-only group were only required to write down their three good things daily without sharing them with others. The control group received information about mental health promotion once a week for a month. The primary outcome was probable depression. Secondary outcomes were anxiety, positive and negative affect, gratitude, happiness and social support. These outcomes were assessed at baseline, 1, 3, 6 and 12 months after the intervention. Repeated-measures analyses were conducted using generalised estimation equations. The study was registered with the Chinese Clinical Trial Registry (ChiCTR-TRC-13003252). Between June 2013 and May 2015, 404 participants were enrolled and randomly assigned to either the TGT-SN (n = 129), TGT-only (n = 139) or control group (n = 136). The main effects of TGT-SN (adjusted odds ratio (aOR) = 0.75, 95% CI 0.52-1.09; p = 0.131) and TGT-only (aOR = 0.83, 95% CI 0.57-1.21; p = 0.332) in reducing depression were statistically non-significant. The participants of the TGT-SN group showed significantly lower anxiety symptoms (aOR = 0.62, 95% CI 0.43-0.89; p = 0.009) and negative affect (β = -1.62, 95% CI 2.98 to -0.26; p = 0.019) over time compared with those of the control group. No significant main effect was found for any secondary outcomes for the TGT-only group. The novel intervention combining the TGT exercise with electronic social networking was found effective in reducing anxiety and negative affect among HIVMSM.