Sleep disturbances are associated with poor long-term memory (LTM) formation, yet the underlying cell types and neural circuits involved have not been fully decoded. Dopamine neurons (DANs) are involved in memory processing at multiple stages. Here, using both male and female flies, Drosophila melanogaster , we show that, during the first few hours of memory consolidation, disruption of basal activity of a small subset of protocerebral anterior medial DANs (PAM-DANs), by either brief activation or inhibition of the two dorsal posterior medial (DPM) neurons, impairs 24 h LTM. Interestingly, these brief changes in activity using female flies result in sleep loss and fragmentation, especially at night. Pharmacological rescue of sleep after manipulation restores LTM. A specific subset of PAM-DANs (PAM-α1) that synapse onto DPM neurons specify the microcircuit that links sleep and memory. PAM-DANs, including PAM-α1, form functional synapses onto DPM mainly via multiple dopamine receptor subtypes. This PAM-α1 to DPM microcircuit exhibits a synchronized, transient, post-training increase in activity during the critical memory consolidation window, suggesting an effect of this microcircuit on maintaining the sleep necessary for LTM consolidation. Our results provide a new cellular and circuit basis for the complex relationship between sleep and memory.