Memories are initially encoded in the hippocampus but subsequently consolidated to the cortex. Although synaptic plasticity is key to these processes, its precise spatiotemporal profile remains poorly understood. Using optogenetics to selectively erase long-term potentiation (LTP) within a defined temporal window, we found that distinct phases of synaptic plasticity play differential roles. The first wave acts locally in the hippocampus to confer context specificity. The second wave, during sleep on the same day, organizes these neurons into synchronously firing assemblies. Finally, LTP in the anterior cingulate cortex during sleep on the second day is required for further stabilization of the memory. This demonstrates the precise localization, timing, and characteristic contributions of the plasticity events that underlie the early phase of memory consolidation.