Conditions experienced during development have often long-lasting effects persisting into adulthood. In Drosophila, it is well-documented that larval crowding influences fitness-related traits such as body size, starvation resistance and lifespan. However, the underlying mechanism of this phenomenon is not well understood. Here, we show that the effects of increased larval density on life-history traits can be explained by decreased yeast availability in the diet during development. Yeast-poor larval diet alters various life-history traits and mimics the effects of larval crowding. In particular, reduced amount of yeast in larval diet prolongs developmental time, reduces body size, increases body fat content and starvation resistance, and prolongs Drosophila lifespan. Conversely, the effects of larval crowding can be rescued by increasing the concentration of the dietary yeast in the diet during development. Altogether, our results show that the well-known effects of larval crowding on life-history traits are mainly caused by the reduced availability of dietary yeasts due to increased larval competition.