How cold-blooded animals acclimate to temperature and what determines the limits of their viable temperature range are not understood. Here, we show that Drosophila alter their dietary preference from yeast to plants when temperatures drop below 15 degrees C and that the different lipids present in plants improve survival at low temperatures. We show that Drosophila require dietary unsaturated fatty acids present in plants to adjust membrane fluidity and maintain motor coordination. Feeding on plants extends lifespan and survival for many months at temperatures consistent with overwintering in temperate climates. Thus, physiological alterations caused by a temperature-dependent dietary shift could help Drosophila survive seasonal temperature changes.