Mangrove forests are one of the most productive and seriously threatened ecosystems in the world. The widespread invasion ofSpartina alterniflorahas seriously imperiled the security of mangroves as well as coastal mudflat ecosystems. Based on a model evaluation index, we selected RF, GBM, and GLM as a predictive model for building a high-precision ensemble model. We used the species occurrence records combined with bioclimate, sea–land topography, and marine environmental factors to predict the potentially suitable habitats of mangrove forests and the potentially suitable invasive habitats ofS. alterniflorain the southeastern coast of China. We then applied the invasion risk index (IRI) to assess the risk thatS. alterniflorawould invade mangrove forests. The results show that the suitable habitats for mangrove forests are mainly distributed along the coastal provinces of Guangdong, Hainan, and the eastern coast of Guangxi. The suitable invasive habitats forS. alternifloraare mainly distributed along the coast of Zhejiang, Fujian, and relatively less in the southern provinces. The high-risk areas forS. alterniflorainvasion of mangrove forests are concentrated in Zhejiang and Fujian. Bioclimate variables are the most important variables affecting the survival and distribution of mangrove forests andS. alterniflora. Among them, temperature is the most important environmental variable determining the large-scale distribution of mangrove forests. Meanwhile,S. alterniflorais more sensitive to precipitation than temperature. Our results can provide scientific insights and references for mangrove forest conservation and control ofS. alterniflora.