In desert locusts, increased population densities drive phenotypic transformation from the solitarious to the gregarious phase within a generation [1-4]. Here we show that when presented with odor-food associations, the two extreme phases differ in aversive but not appetitive associative learning, with solitarious locusts showing a conditioned aversion more quickly than gregarious locusts. The acquisition of new learned aversions was blocked entirely in acutely crowded solitarious (transiens) locusts, whereas appetitive learning and prior learned associations were unaffected. These differences in aversive learning support phase-specific feeding strategies. Associative training with hyoscyamine, a plant alkaloid found in the locusts' habitat [5, 6], elicits a phase-dependent odor preference: solitarious locusts avoid an odor associated with hyoscyamine, whereas gregarious locusts do not. Remarkably, when solitarious locusts are crowded and then reconditioned with the odor-hyoscyamine pairing as transiens, the specific blockade of aversive acquisition enables them to override their prior aversive memory with an appetitive one. Under fierce food competition, as occurs during crowding in the field, this provides a neuroecological mechanism enabling locusts to reassign an appetitive value to an odor that they learned previously to avoid.