Metabolomics provides an unprecedented window on diverse plant secondary metabolites that represent a potentially critical niche dimension in tropical forests underlying co-existence. Here, we used untargeted metabolomics to evaluate the chemical composition of 358 tree species and its relationship to phylogeny and variation in light environment, soil nutrients, and insect-herbivore leaf damage in a tropical rain forest plot. We found that tree species that co-occur locally are less chemically similar than random, and that local chemical dispersion and metabolite diversity reduce herbivory, especially that of specialist insect herbivores. Our results suggest that plant secondary metabolites have the potential to mediate plant-herbivore interactions in a manner consistent with diversity maintenance at the community scale.