Body size profoundly affects many aspects of animal biology, including metamorphosis, allometry, size-dependent alternative pathways of gene expression, and the social and ecological roles of individuals. However, regulation of body size is one of the fundamental unsolved problems in developmental biology. The control of body size requires a mechanism that assesses size and stops growth within a characteristic range of sizes. Under normal growth conditions in Manduca sexta, the endocrine cascade that causes the brain to initiate metamorphosis starts when the larva reaches a critical weight. Metamorphosis is initiated by a size-sensing mechanism, but the nature of this mechanism has remained elusive. Here we show that this size-sensing mechanism depends on the limited ability of a fixed tracheal system to sustain the oxygen supply to a growing individual. As body mass increases, the demand for oxygen also increases, but the fixed tracheal system does not allow a corresponding increase in oxygen supply. We show that interinstar molting has the same size-related oxygen-dependent mechanism of regulation as metamorphosis. We show that low oxygen tension induces molting at smaller body size, consistent with the hypothesis that under normal growth conditions, body size is regulated by a mechanism that senses oxygen limitation. We also found that under poor growth conditions, larvae may never attain the critical weight but eventually molt regardless. We show that under these conditions, larvae do not use the critical weight mechanism, but instead use a size-independent mechanism that is independent of the brain.