Importance Suicidality poses a serious global health concern, particularly in the sexual and gender minority population. While various studies have focused on investigating chronic stressors, the precise prediction effect of daily experiences on suicide ideation remains uncertain. Objective To test the extent to which mood fluctuations and contextual stressful events experienced by sexual and gender minority individuals may predict later short- and long-term suicide ideation. Design, Setting, and Participants This diagnostic study collected twice-daily data on mood states and stressful events from sexual and gender minority individuals over 25 days throughout 3 waves of the Chinese Lunar New Year (before, during, and after), and follow-up surveys assessing suicidal ideation were conducted 1, 3, and 8 months later. Online recruitment advertisements were used to recruit young adults throughout China. Eligible participants were self-identified as sexual and gender minority individuals aged 18 to 29 years. Those who were diagnosed with psychotic disorders (eg, schizophrenia spectrum or schizotypal disorder) or prevented from objective factors (ie, not having a phone or having an irregular sleep rhythm) were excluded. Data were collected from January to October 2022. Main Outcomes and Measures To predict short-term (1 month) and longer-term (3 and 8 months) suicidal ideation, the study tested several approaches by using machine learning including chronic stress baseline data (baseline approach), dynamic patterns of mood states and stressful events (ecological momentary assessment [EMA] approach), and a combination of baseline data and dynamic patterns (EMA plus baseline approach). Results A total of 103 sexual and gender minority individuals participated in the study (mean [SD] age, 24.2 [2.5] years; 72 [70%] female). Of these, 19 (18.4%; 95% CI, 10.9%-25.9%), 25 (24.8%; 95% CI, 16.4%-33.2%), 30 (29.4%; 95% CI, 20.6%-38.2%), and 32 (31.1%; 95% CI, 22.2%-40.0%) reported suicidal ideation at baseline, 1, 3, and 8 months follow-up, respectively. The EMA approach showed better performance than the baseline and baseline plus EMA approaches at 1-month follow-up (area under the receiver operating characteristic curve [AUC], 0.80; 95% CI, 0.78-0.81) and slightly better performance on the prediction of suicidal ideation at 3 and 8 months’ follow-up. In addition, the best approach predicting suicidal ideation was obtained during Lunar New Year period at 1-month follow-up, which had a mean AUC of 0.77 (95% CI, 0.74-0.79) and better performance at 3 and 8 months’ follow-up (AUC, 0.74; 95% CI, 0.72-0.76 and AUC, 0.72; 95% CI, 0.69-0.74, respectively). Conclusions and Relevance The findings in this study emphasize the importance of contextual risk factors experienced by sexual and gender minority individuals at different stages. The use of machine learning may facilitate the identification of individuals who are at risk and aid in the development of personalized process-based early prevention programs to mitigate future suicide risk.