Spatial memories guide navigation efficiently toward desired destinations. However, the neuronal and circuit mechanisms underlying the encoding of goal locations and its translation into goal-directed navigation remain unclear. Here we demonstrate that mice rapidly form a spatial memory of a shelter during shelter experiences, guiding escape behavior toward the goal location-a shelter-when under threat. Dopaminergic neurons in the ventral tegmental area and their projection to the nucleus accumbens (NAc) encode safety signals associated with the shelter. Optogenetically induced phasic dopamine signals are sufficient to create a place memory that directs escape navigation. Converging dopaminergic and hippocampal glutamatergic inputs to the NAc mediate the formation of a goal-related memory within a subpopulation of NAc neurons during shelter experiences. Artificial co-activation of this goal-related NAc ensemble with neurons in the dorsal periaqueductal gray was sufficient to trigger memory-guided, rather than random, escape behavior. These findings provide causal evidence of cognitive circuit modules linking memory with goal-directed action.