Surface-associated lifestyles dominate in the bacterial world. Large multicellular assemblies, called biofilms, are essential to the survival of bacteria in harsh environments and are closely linked to antibiotic resistance in pathogenic strains. Biofilms stem from the surface colonization of a wide variety of substrates encountered by bacteria, from living tissues to inert materials. Here, we demonstrate experimentally that the promiscuous opportunistic pathogenPseudomonas aeruginosaexplores substrates differently based on their rigidity, leading to striking variations in biofilm structure, exopolysaccharides (EPS) distribution, strain mixing during co-colonization and phenotypic expression. Using simple kinetic models, we show that these phenotypes arise through a mechanical interaction between the elasticity of the substrate and the type IV pilus (T4P) machinery, that mediates the surface-based motility called twitching. Together, our findings reveal a new role for substrate softness in the spatial organization of bacteria in complex microenvironments, with far-reaching consequences on efficient biofilm formation.