Identifying the processes underlying community assembly and dynamics remains a central goal in ecology. Although much research has been devoted to analyzing how environmental changes affect patterns of trait and species diversity among communities and ecosystems, few studies have resolved the link between fundamental processes, species diversity and trait distributions. It has been suggested that identifying ecological selection on functional traits may provide insight into more general rules of community assembly. In this study, we asked whether and how selection determines species and trait diversity, and how this is determined by the initial community-weighted variance (CWV) and mean (CWM) for traits governing species interactions, as in our case: competitiveness and defense against a predator. We tracked experimental 5-species phytoplankton communities in the presence and absence of a rotifer predator. The communities had at least 3 of the 5 species in common, but differed in CWV and CWM for defense against predation. We found that species diversity was only maintained in the presence of the predator, but that species diversity was highest with higher initial trait distributions and that temporal changes in diversity correlated with trait selection. For low or higher initial distributions, we found early directional selection for defense and competitiveness, followed by reduced selection and an increase in niche availability. For intermediate initial trait distributions, we observed initial directional selection in only one trait followed by stabilizing selection. We attribute changes in selection for defense and competitiveness, and thus species diversity, to changes in predator density, which were more dynamically stable for communities with higher trait diversity. Overall, our results suggest that the initial trait distribution determined species diversity through a feedback loop with changes in selection on traits and predator density.