1. How plants allocate their biomass to different organs is essential to understanding plant adaptations and distributions. Overall, biomass allocation may follow fixed rules across taxa. They are also likely to exhibit substantial departure from these rules during ontogeny and in response to particular limiting factors to optimize their growth and maximize their survival. However, how plants adjust their allocation priorities depending on size and age across stress gradients remain largely unknown in wild populations. 2. We examined ontogenetic variation in biomass allocation in Himalayan forb Potentilla pamirica across its 5,250-5,900-m elevation range, between populations from dry steppe, wet alpine and cold subnival zone. We evaluated whether biomass allocation followed optimal partitioning or fixed allometric rules using organ mass in 1,019 individuals spanning 1-73 years. 3. We found shifting biomass fractions with plant size and age, supporting the optimal partitioning theory. Young plants (<10 years) allocated similar proportions of biomass to leaves, stems and roots, intermediate-aged plants (10-30 years) allocated more biomass to roots, while the oldest plants had 90% biomass in belowground stems. 4. Major developmental processes including secondary thickening, branching and flowering begin 10-15 years earlier under more thermally favourable steppe conditions. Young steppe plants are larger than alpine and subnival plants, but these differences disappear in plants aged ~30, and the oldest alpine and subnival plants are larger than steppe plants. 5. Plant age exerted significant control over biomass allocation after controlling for plant size. While in steppe plants the preference for stem biomass allocation increases with both size and age, for large alpine and subnival plants the stem prioritization decreases with age in favour of root and leaf mass fractions. We interpret root and leaf prioritization in older plants as a way to reduce carbon imbalances and the risk of frost damage to secure long life. 6. Our analyses rejected ontogenetically fixed allometry and instead found high variation in biomass allocation depending on age, size and environment, supporting optimal partitioning theory. The uneven allocation of resources to different structures and functions during ontogenesis reflects plant adaptations | 33 Functional Ecology DOLEZAL Et AL.