Global marine biodiversity loss impairs entire ecosystems and their stability. Robust biodiversity estimates are key to inform policies and management strategies, and need to consider the contribution of diverse habitats, including those for which estimates of biodiversity are scattered or totally absent. This study assessed the fish diversity associated with three main coastal habitats (rocky bottoms, Posidonia oceanica meadows, sandy bottoms), and their role in shaping the overall coastal fish diversity, also in relation to potential environmental and anthropogenic drivers affecting patterns of fish diversity in coastal areas. Using underwater visual census, we sampled 62 sites distributed on the three habitats, for a total of 496 replicates. We assessed the contribution of each habitat to β-diversity, divided into Local Contribution to β-diversity (LCBD), a comparative indicator of the contributions to β-diversity of each habitat, and Species Contribution to β-diversity (SCBD), which measures the relative importance of each species in affecting β-diversity. Finally, we modelled species diversity in relation to potential environmental and anthropogenic drivers. Overall, 72 species were recorded, with the highest species richness observed on rocky bottoms (56 species, 16 unique to this habitat), followed by P. oceanica (38 species, 0 unique) and sandy bottoms (32 species, 14 unique). Sandy bottom assemblages had a significantly higher contribution to LCBD than P. oceanica meadows and rocky bottoms, and two of the five species with the highest contribution to SCBD are exclusively associated with sandy bottoms. Finally, sea surface temperature, sea surface salinity, and habitat were highlighted as significant predictors of species richness. Our findings, aside from highlighting the environmental drivers of coastal fish diversity in the Mediterranean Sea, unravel the potential key role of sandy bottoms in contributing to overall coastal fish diversity and can inform conservation planning.