The evolution of foraging in Drosophila melanogaster (Meigen) is studied using outbred populations that had been differentiated using laboratory selection. The foraging behaviour of Drosophila larvae is measured using the foraging path length of 72-h-old larvae. The foraging path length is the distance travelled by foraging larvae over 5 min. Populations of Drosophila selected for rapid development show significantly greater path lengths than their controls. Populations of Drosophila selected for resistance to ammonia and urea in their larval food have shorter path lengths than their controls. Individuals in the ammonia-resistant populations are smaller than those in the control populations, but the size-adjusted metabolic rates are not significantly different. A simple model is proposed suggesting that changes in larval foraging behaviour may be a means for Drosophila larvae to adapt to new environments that require additional maintenance energy. In the ammonia-selected populations, crucial tests of these ideas will have to be conducted in environments with ammonia.