We investigated the spatial and temporal changes of benthic macroinvertebrate communities in response to floods and droughts in three different stream types: perennial, intermittent, and ephemeral. Benthic macroinvertebrates were collected monthly (or biweekly) at six different sampling sites from July 2006 to January 2008. Species richness and abundance were extremely low at all sampling sites during the flooding period, but the communities subsequently recovered rapidly within 1 month. The effects of floods and droughts on benthic macroinvertebrates manifested differently among the three different stream types. Species richness and abundance had a negative relationship with the amount of precipitation in the perennial stream type, whereas no significant relationship was observed in the ephemeral stream type. A Self-Organizing Map, an unsupervised artificial neural network, classified the samples into four clusters based on the similarities of community composition, reflecting the different effects of floods and droughts on the different stream types. Our results suggest that floods and droughts are the defining characteristics of streams, spatial heterogeneity (i.e. the perennial stream type) can decrease the effect of temporal heterogeneity, and both spatial and temporal heterogeneities are important for structuring the environmental condition and benthic macroinvertebrate assemblages. Copyright © 2012 John Wiley & Sons, Ltd.