Collective phenomena emerge from the interaction of natural or artificial units with a complex organization. The interplay between structural patterns and dynamics might induce functional clusters that, in general, are different from topological ones. In biological systems, like the human brain, the overall functionality is often favored by the interplay between connectivity and synchronization dynamics, with functional clusters that do not coincide with anatomical modules in most cases. In social, socio-technical and engineering systems, the quest for consensus favors the emergence of clusters.Despite the unquestionable evidence for mesoscale organization of many complex systems and the heterogeneity of their inter-connectivity, a way to predict and identify the emergence of functional modules in collective phenomena continues to elude us. Here, we propose an approach based on random walk dynamics to define the diffusion distance between any pair of units in a networked system. Such a metric allows to exploit the underlying diffusion geometry to provide a unifying framework for the intimate relationship between metastable synchronization, consensus and random search dynamics in complex networks, pinpointing the functional mesoscale organization of synthetic and biological systems.The absence of a central authority coordinating the interactions among units of a complex system might lead to interesting collective phenomena, such as synchronization [1] in biological systems or consensus [2] in social and technological networks. This type of self-organization is affected by the underlying structure, which for a wide variety of real systems is highly heterogenous [3] and modular [4,5]. Understanding the interplay between structure and dynamics of such systems has been, and still is, a major challenge in the study of complex systems. Empirical observations, confirmed by numerical simulations and theoretical predictions, suggest that complex systems with hierarchical and/or modular mesoscale organization of their units [6] are characterized by topological scales [7] and the emergence of functional clusters that might be, in general, different from topological ones.In this letter, we show that such functional clusters might be predicted and identified for a wide variety of complex networks. More specifically, for biological systems which can be modeled as networks of oscillators, and for systems of individuals or sensors attempting to reach consensus. The unifying picture is provided by diffusion geometry [8], developed one decade ago for nonlinear dimensionality reduction of complex data. This approach uses Markov processes to integrate local similarities at different scales, allowing to approximate the manifold which better describes the data while preserving their topological features. From a physical perspective, this approach relies on topological information gathered by random searches across time, a principle that has been used successfully in network science to unravel the topological mesoscale organization of ...