Memory consolidation during sleep is thought to depend on the coordinated interplay between cortical slow waves, thalamocortical sleep spindles and hippocampal ripples, but direct evidence is lacking. Here, we implemented real-time closed-loop deep brain stimulation in human prefrontal cortex during sleep and tested its effects on sleep electrophysiology and on overnight consolidation of declarative memory. Synchronizing the stimulation to the active phases of endogenous slow waves in the medial temporal lobe (MTL) enhanced sleep spindles, boosted locking of brain-wide neural spiking activity to MTL slow waves, and improved coupling between MTL ripples and thalamocortical oscillations. Furthermore, synchronized stimulation enhanced the accuracy of recognition memory. By contrast, identical stimulation without this precise time-locking was not associated with, and sometimes even degraded, these electrophysiological and behavioral effects. Notably, individual changes in memory accuracy were highly correlated with electrophysiological effects. Our results indicate that hippocampo–thalamocortical synchronization during sleep causally supports human memory consolidation.