Barringtonia racemosa (L.) Spreng. (Lecythidaceae), a crucial species in mangrove ecosystems, is facing endangerment primarily due to habitat loss. To address this issue, research is imperative to identify suitable conservation habitats for the endangered B. racemosa within mangrove ecosystems. The utilization of the optimized Maximum Entropy (MaxEnt) model has been instrumental in predicting potential suitable regions based on global distribution points and environmental variables under current and future climates conditions. The study revealed that the potential distribution area of B. racemosa closely aligns with its existing range with an Area Under the Curve (AUC) greater than 0.95. The Jackknife, AUC, percent contribution (PC), and permutation importance (PI) tests were employed alongside the optimized MaxEnt model to examine the influence of environmental variables on the distribution of B. racemosa. The primary factors identified as significant predictors of B. racemosa distribution included the average temperature of the ocean surface (Temperature), average salinity of the ocean surface (Salinity), precipitation of the warmest quarter (Bio18), precipitation of the driest month (Bio14), seasonal variation coefficient of temperature (Bio4), and isothermality (Bio3). Currently, the habitat range of B. racemosa is predominantly found in tropical and subtropical coastal regions near the equator. The total suitable habitat area measures 246.03 km2, with high, medium, low, and unsuitable areas covering 3.90 km2, 8.57 km2, 16.94 km2, and 216.63 km2, respectively. These areas represent 1.58%, 3.48%, 6.88%, and 88.05% of the total habitat area, respectively. The potential distribution area of B. racemosa demonstrated significant variations under three climate scenarios (SSP126, SSP245, and SSP585), particularly in Asia, Africa, and Oceania. Both low and high suitable areas experienced a slight increase in distribution. In summary, the research suggests that B. racemosa primarily flourishes in coastal regions of tropical and subtropical areas near the equator, with temperature and precipitation playing a significant role in determining its natural range. This study offers important implications for the preservation and control of B. racemosa amidst habitat degradation and climate change threats. Through a comprehensive understanding of the specific habitat needs of B. racemosa and the implementation of focused conservation measures, efforts can be made to stabilize and rejuvenate its populations in their natural environment.