Suicidal ideation (SI) assumes a pivotal role in predicting suicidal behaviors. The incidence of SI among high (junior and senior) school students is significantly higher than that of other age groups. The aim of this study is to explore the gender differences in SI among high school students in Yunnan Province. A total of 6180 students in grades 7-12 in Yunnan province, China from May 2021 to May 2022 participated in this survey. Univariate analysis was employed to describe the influencing factors of male and female students' SI. Subsequently, data were stratified by gender. Adopting machine learning technique, including Least Absolute Shrinkage and Selection Operator (Lasso) and Boruta algorithm, and logistic regression model to estimate the direction and effect magnitude of the influencing factors. The prevalence of SI was significantly higher for females (31.34%) than males (16.73%). The logistic regression model was established using the variables screened by Boruta algorithm, indicated that anxiety, depression, suffering emotion abuse or emotion neglect in childhood, non-suicidal self-injury, evening chronotype are common risk factors for SI in male and female students. Notably, female students who exhibited aggressive behavior, have experienced bullying, and were in the junior high school learning stage were more likely to report SI than their male counterparts. Females showed more vulnerability to SI than males especially among females in junior high school, reporting aggressive behavior and bullying experiences. Tailored prevention strategies, informed by these gender-related distinctions, should be developed and implemented.