Dendritic spines show rapid motility and plastic morphology, which may mediate information storage in the brain. It is presently believed that polymerization/depolymerization of actin is the primary determinant of spine motility and morphogenesis. Here, we show that myosin IIB, a molecular motor that binds and contracts actin filaments, is essential for normal spine morphology and dynamics and represents a distinct biophysical pathway to control spine size and shape. Myosin IIB is enriched in the postsynaptic density (PSD) of neurons. Pharmacologic or genetic inhibition of myosin IIB alters protrusive motility of spines, destabilizes their classical mushroom-head morphology, and impairs excitatory synaptic transmission. Thus, the structure and function of spines is regulated by an actin-based motor in addition to the polymerization state of actin.