Within-species Individual Trait Variation (ITV) is now recognised as an important source of variability in ecological communities. Individual variation in trophic niche traits (i.e. individual niche width and between-individual variation) can greatly modify top-down and/or competitive interactions. Trophic traits vary according to variation in ecological opportunity, which represents the range of exploitable resources. While the role of prey availability in driving trophic traits is well-established, abiotic drivers (e.g. habitat structure) are rarely accounted for, or are solely considered via their effect on the prey community. We aimed to disentangle prey-mediated from direct habitat effects on trophic ITV in a critically endangered riverine fish, the Rhone streber (Zingel asper). We quantified individual trophic traits using high-resolution diet data obtained from faeces metabarcoding, and quantified prey availability and habitat structure using a fine-scale sampling protocol. Trophic traits were driven by distinct mechanisms: the individual niche width was driven by prey availability, while between-individual variation was largely driven by habitat conditions. Habitat conditions acted both directly on trophic traits and indirectly via their effect on the prey community. By simultaneously accounting for biotic and abiotic drivers of trophic ITV, we obtained a more complete understanding of how prey availability and habitat structure jointly determine ecological opportunity. Furthermore, by accounting for fine-scale variation in prey community and habitat conditions, the importance of spatial heterogeneity factors was highlighted. This study demonstrates how robust metabarcoding data, combined with detailed prey community and habitat information can be used to reveal the mechanistic pathways that drive trophic traits.