We introduce a novel method for detecting anatomic and functional structures in fMRI. The main idea is to divide the data hierarchically into smaller groups using k-means clustering. The separation is halted if the clusters contain no further structure that is verified by several independent tests. The resulting cluster centers are then used for computing the final results in one step. The procedure is flexible, fast to compute, and the numbers of clusters in the data are obtained in a data-driven manner. Applying the algorithm to synthetic fMRI data yields perfect separation of "anatomic," i.e., time-invariant, and "functional," i.e., time-varying, information for a standard off-on paradigm and a typical functional contrast-to-noise ratio of two and higher. In addition, an EPI-fMRI data set of the human motor cortex was analyzed to demonstrate the performance of this novel approach in vivo.