Human brain functional networks are embedded in anatomical space and have topological properties--small-worldness, modularity, fat-tailed degree distributions--that are comparable to many other complex networks. Although a sophisticated set of measures is available to describe the topology of brain networks, the selection pressures that drive their formation remain largely unknown. Here we consider generative models for the probability of a functional connection (an edge) between two cortical regions (nodes) separated by some Euclidean distance in anatomical space. In particular, we propose a model in which the embedded topology of brain networks emerges from two competing factors: a distance penalty based on the cost of maintaining long-range connections; and a topological term that favors links between regions sharing similar input. We show that, together, these two biologically plausible factors are sufficient to capture an impressive range of topological properties of functional brain networks. Model parameters estimated in one set of functional MRI (fMRI) data on normal volunteers provided a good fit to networks estimated in a second independent sample of fMRI data. Furthermore, slightly detuned model parameters also generated a reasonable simulation of the abnormal properties of brain functional networks in people with schizophrenia. We therefore anticipate that many aspects of brain network organization, in health and disease, may be parsimoniously explained by an economical clustering rule for the probability of functional connectivity between different brain areas.