Understanding the process underlying species coexistence is crucial in ecology. This challenge is relevant in tree communities inhabiting contrasting abiotic conditions, such as lowland floodplain and shallow hillslope karstic systems. We examined the influence of topographic variables and spatial factors on the structure of tree communities in the karstic system in Calakmul, Mexico. We measured 7050 trees (diameter at breast height ≥ 3 cm) in 152 circular plots and generated seven topographic variables from a digital elevation model. We employed redundancy analysis and variance partitioning to test the effects of environmental and spatial factors on tree communities. In addition, we used the null Raup–Crick model to uncover the relative importance of the deterministic and stochastic processes driving community assembly. Our study revealed significant floristic distinction between seasonally flooded and upland forests. The topographic wetness index (TWI) contribution to explaining the floristic differentiation in the studied tree assemblages was greater than that of the other topography-related variables. The explanatory power of the environmental and spatial factors varied slightly between datasets. The null model indicated a predominant influence of deterministic over stochastic processes. Our findings reaffirm the role of seasonal flooding as an abiotic filter. Additionally, the TWI can serve to identify flood-prone conditions within shallow depressions. The preservation of adjacent seasonally flooded and upland forests is relevant for the maintenance of tree diversity in the karst of the Yucatan Peninsula, since flooding drives the distribution of species.