It has been proposed that fertile soils reduce the incidence of gall-forming insect (GFI) species in plant communities. This is known as the soil fertility hypothesis. The main objective of this study was to analyze the spatial distribution of GFI species under different habitats in a tropical dry forest at the Chamela-Cuixmala Biosphere Reserve, Mexico. Eight habitats which differ in soil type, topography, nutrient availability and vegetation were chosen. We found that 38 GFI species specialize on their host plant species. GFI species richness was negatively correlated with phosphorous and nitrogen availability. Using phosphorous as an indicator of soil fertility, we found low frequency and density of GFI on fertile soils. Our study indicates that soil fertility is one of the factors that negatively affects the patterns of spatial distribution of species richness, incidence and abundance of GFI at the community level in two different ways: i) indirectly affecting GFI species richness in plants adapted to infertile soils and ii) directly affecting GFI responses to plant traits of hosts found in a fertility gradient.