Dynamic remodeling of spiny synapses is crucial for cortical circuit development, refinement and plasticity, whereas abnormal morphogenesis is associated with neuropsychiatric disorders. We found that activation of Epac2, a PKA-independent cAMP target and Rap guanine-nucleotide exchange factor (GEF), in cultured rat cortical neurons induced spine shrinkage, increased spine motility, removed synaptic GluR2/3-containing AMPA receptors and depressed excitatory transmission, whereas its inhibition promoted spine enlargement and stabilization. Epac2 was required for dopamine D1-like receptor-dependent spine shrinkage and GluR2 removal from spines. Epac2 interaction with neuroligin promoted its membrane recruitment and enhanced its GEF activity. Rare missense mutations in the EPAC2 (also known as RAPGEF4) gene, previously found in individuals with autism, affected basal and neuroligin-stimulated GEF activity, dendritic Rap signaling, synaptic protein distribution and spine morphology. Thus, we identify a previously unknown mechanism that promotes dynamic remodeling and depression of spiny synapses, disruption of which may contribute to some aspects of disease.