Obsessive-compulsive disorder (OCD) is an anxiety-spectrum disorder characterized by persistent intrusive thoughts (obsessions) and repetitive actions (compulsions). Dysfunction of cortico-striato-thalamo-cortical circuitry is implicated in OCD, although the underlying pathogenic mechanisms are unknown. SAP90/PSD95-associated protein 3 (SAPAP3; also known as DLGAP3) is a postsynaptic scaffolding protein at excitatory synapses that is highly expressed in the striatum. Here we show that mice with genetic deletion of Sapap3 exhibit increased anxiety and compulsive grooming behaviour leading to facial hair loss and skin lesions; both behaviours are alleviated by a selective serotonin reuptake inhibitor. Electrophysiological, structural and biochemical studies of Sapap3-mutant mice reveal defects in cortico-striatal synapses. Furthermore, lentiviral-mediated selective expression of Sapap3 in the striatum rescues the synaptic and behavioural defects of Sapap3-mutant mice. These findings demonstrate a critical role for SAPAP3 at cortico-striatal synapses and emphasize the importance of cortico-striatal circuitry in OCD-like behaviours.