Integrating microbial physiology and biomass stoichiometry opens far-reaching possibilities for linking microbial dynamics to ecosystem processes. For example, the growth-rate hypothesis (GRH) predicts positive correlations among growth rate, RNA content, and biomass phosphorus (P) content. Such relationships have been used to infer patterns of microbial activity, resource availability, and nutrient recycling in ecosystems. However, for microorganisms it is unclear under which resource conditions the GRH applies. We developed a model to test whether the response of microbial biomass stoichiometry to variable resource stoichiometry can be explained by a trade-off among cellular components that maximizes growth. The results show mechanistically why the GRH is valid under P limitation but not under N limitation. We also show why variability of growth rate-biomass stoichiometry relationships is lower under P limitation than under N or C limitation. These theoretical results are supported by experimental data on macromolecular composition (RNA, DNA, and protein) and biomass stoichiometry from two different bacteria. In addition, compared to a model with strictly homeostatic biomass, the optimization mechanism we suggest results in increased microbial N and P mineralization during organic-matter decomposition. Therefore, this mechanism may also have important implications for our understanding of nutrient cycling in ecosystems.