Synapses are the sites where neurons contact each other and exchange information in the brain. Experience-dependent changes in synaptic connections are fundamental for numerous neurological processes, ranging from the development of neuronal circuitry to learning and memory. Dendritic spines are the postsynaptic sites of the majority of excitatory synapses in the mammalian central nervous system. The morphology and dynamics of dendritic spines change throughout the lifespan of animals, especially during early postnatal development and in response to novel experiences. Furthermore, abnormal spine morphology is a hallmark of various types of neuropathology. For instance, Fragile X syndrome (FXS) is characterized by an abnormal increase in immature spines. However, how learning behaviors affect neuronal connectivity and how the memory is structurally encoded in the intact brain, what molecular mechanisms regulate experience-dependent synaptic pruning during postnatal development, and how synaptic connections are altered during the progression of neuropathology remain unknown. To investigate how long-lasting motor memory is structurally encoded in the intact brain, we train mice with novel motor skills and apply two-photon in vivo imaging to follow the dynamisms of dendritic spines in the corresponding motor cortex. We find that learning a new motor skill task leads to a rapid formation of postsynaptic dendritic spines on the output pyramidal neurons in the motor cortex. Although selective elimination of spines that existed before training gradually returns the overall spine density back to the original level, the new spines induced during learning are preferentially stabilized during subsequent training and endure long after training stops. Furthermore, we show that different motor skills are encoded by different sets of synapses. Practice of novel, but not previously learned, tasks further promotes spinogenesis in adulthood. Our findings, therefore, reveal rapid, but long-lasting, synaptic reorganization is closely associated with motor learning. The data also suggest that stabilized neuronal connections are the foundation of durable motor memory.To explore molecular mechanisms underlying experience-dependent synaptic pruning during postnatal development, we investigate the elimination of dendritic spines in mice deficient of different cell adhesion molecules ephrin-As in vivo, and also examine the expression patterns of those molecules using array tomography. We find that elimination of postsynaptic dendritic spines in various cortical regions is accelerated in ephrin-A2 knockout (KO) mice during adolescent development, resulting in fewer adolescent spines integrated into adult circuits. Sensory deprivation reduces spine elimination in the barrel cortex, and deprived wild-type and deprived KO mice exhibit comparable spine elimination. We also show that ephrin-A2 in the cortex colocalizes with glial glutamate transporters (GLAST and GLT-1), which are significantly down-regulated in ephrin-A2 KOs. Finally, we find that increased spine loss in ephrin-A2 KOs depends on activation of glutamate receptors, as blockade of the NMDA (N-methyl-D-aspartate) receptor by its antagonist MK801 eliminates the difference in spine loss between wild-type and ephrin-A2 KO mice. Together, our results suggest that ephrin-A2 signaling underlies experience-dependent, NMDA receptor-mediated synapse elimination during maturation of the mouse cortex.Fragile X Syndrome (FXS) is the most frequent form of inherited mental retardation. This mental disorder is caused by transcriptional silence of a gene called fragile X mental retardation gene 1 (FMR1). It has been hypothesized that absence of the Fragile X Mental Retardation Protein (FMRP, the protein product of FMR1) causes a defect in spine maturation and pruning, and such altered synaptic connectivity results in learning defects. To test this hypothesis, we train both wild-type and FMR1 KO mice with motor learning tasks and follow the dynamics of dendritic spines at different age stages in vivo. We find that adult FMR1 KO mice fail to improve skilled motor performance, suggesting a defect in learning behaviors. We also show that layer V neurons do not prune dendritic spines during postnatal development in FMR1 KO mice, therefore, causing significantly higher spine density in adulthood. Moreover, while adult FMR1 KO mice have normal spine turnover, adolescent FMR1 KO mice exhibit elevated spine formation and stabilization, but normal spine removal. Additionally, abnormal spine dynamics in adolescent FMR1 KO mice are layer-specific, as dendritic spines on apical dendrites of layer II/III neurons display normal spine turnover. Finally, administration of mGluR antagonist MPEP rescues the defects of spine dynamics in adolescent FMR1 KO mice, providing a potential therapeutic target for FXS.