Many animals exhibit ontogenetic niche shifts as they grow, which strongly affects population dynamics. However, such niche shifts can be constrained by the physical environment which the population occupies. To study this, we develop a physiologically-structured population model parameterized for brown trout, and vary the availability of a stream used as an exclusive juvenile nursery habitat. We find fewer but large, fast-growing adults in lakes with small streams, and more but smaller, slow-growing adults in lakes with large streams. We show that the mechanism behind this pattern is a reduced ability of cannibals to control juvenile survival in the lake with increasing stream availability. Juveniles emerging from the stream at larger sizes intensify competition with the lake-dwelling adults, leading to slower individual growth. These results are similar for other sources of size-dependent juvenile mortality in the lake. Field data from brown trout lakes across a stream size gradient show the same pattern: reduced trout growth and fewer large individuals in lakes with larger tributary streams. We show how ontogenetic niche shifts and stage-specific habitat availability affect population structure and dynamics through size-dependent mortality and competition. Our results provide an important foundation that may help design effective conservation and restoration strategies.