Both long-term behavioral memory and synaptic plasticity require protein synthesis, some of which may occur locally at specific synapses. Cytoplasmic polyadenylation element-binding (CPEB) proteins are thought to contribute to the local protein synthesis that underlies long-term changes in synaptic efficacy, but a role has not been established for them in the formation of long-term behavioral memory. We found that the Drosophila melanogaster CPEB protein Orb2 is acutely required for long-term conditioning of male courtship behavior. Deletion of the N-terminal glutamine-rich region of Orb2 resulted in flies that were impaired in their ability to form long-term, but not short-term, memory. Memory was restored by expressing Orb2 selectively in fruitless (fru)-positive gamma neurons of the mushroom bodies and by providing Orb2 function in mushroom bodies only during and shortly after training. Our data thus demonstrate that a CPEB protein is important in long-term memory and map the molecular, spatial and temporal requirements for its function in memory formation.