Hippocampal synapses undergo homeostatic rebalancing during sleep by a mechanism that might involve sharp-wave–ripples (SWRs). Here, a closed-loop system was devised in which onset of a SWR triggered optogenetic silencing of the hippocampal pyramidal neurons that generate SWRs. SWR silencing in mice abolished spontaneous synaptic depression in hippocampal CA1 and reduced recall in a spatial memory acquisition test, suggesting that SWRs are involved in homeostatic synaptic downscaling.