Dentate gyrus (DG) is widely thought to provide a teaching signal that enables hippocampal encoding of memories, but its role during retrieval is poorly understood. Somedata and models suggest thatDGplays no role in retrieval; others encourage the opposite conclusion. To resolve this controversy, we evaluated the effects of optogenetic inhibition of dorsal DG during context fear conditioning, recall, generalization, and extinction in male mice. Wefound that (1) inhibition during training impaired context fear acquisition; (2) inhibition during recall did not impair fear expression in the training context, unless mice had to distinguish between similar feared and neutral contexts; (3) inhibition increased generalization of fear to an unfamiliar context that was similar to a feared one and impaired fear expression in the conditioned context when it was similar to a neutral one; and (4) inhibition impaired fear extinction. These effects, as well as several seemingly contradictory published findings, could be reproduced by BACON (Bayesian Context Fear Algorithm), a physiologically realistic hippocampal model positing that acquisition and retrieval both involve coordinated activity in DG and CA3. Our findings thus suggest that DG contributes to retrieval and extinction, as well as to the initial establishment of context fear.