The relationship between the spatial structure of shelter forests and the diversity of understory herbaceous plants in desert–oasis ecotones is important for maintaining biodiversity indices and protecting the oasis ecosystem. In this paper, we explore the coupling relationship between tree layer structure (competition index, angle scale, neighborhood comparison, DBH, etc.) and understory herb diversity in the transition zone of shelter forest plots near oases and near deserts; in addition, we also aim to elucidate the dominant stand structure factors affecting herb biodiversity. The results indicated the following: A total of 13 herbaceous plant species were discovered in the transitional zone, with 11 species found near the oasis area and 4 species near the desert region. The Shannon, Simpson, and Pielou indices of understory herbaceous plants were significantly higher near the oasis area compared to the desert region. The Margalef index mean was higher in the oasis area compared to the desert region. Pearson and canonical correlation analyses revealed significant associations between specific stand structure indicators and diversity in the herbaceous layer. The results of the multiple linear regression analysis revealed that the competition index had a significant impact on the Shannon, Simpson, and Pielou diversity indices of the herbaceous layer in the understory of the shelterbelt forest near the oasis, with corresponding impact coefficients of 0.911, 0.936, and 0.831, respectively. The mingling degree was found to be the primary influencing factor for the Margalef index, with an impact coefficient of 0.825. However, in the understory of the shelterbelt forest near the desert, the neighborhood comparison ratio negatively affected the Shannon and Margalef indices, with impact coefficients of −0.634 and −0.736, respectively. Additionally, tree height negatively impacted the Simpson and Pielou indices, with impact coefficients of −0.645 and −0.677, respectively. In order to enhance the diversity of understory herbaceous species in the transitional zone and preserve the ecological system of the oasis, specific modifications to the forest structure and arrangement are essential. Pruning and thinning are necessary for shelterbelt forests located near desert regions, while shelterbelt forests near oases should use a suitable mix of tree species. These measures can help preserve or enhance the diversity of understory herbaceous plants.