Fear memories guide adaptive behavior in contexts associated with aversive events. The hippocampus forms a neural representation of the context that predicts aversive events. Representations of context incorporate multisensory features of the environment, but must somehow exclude sensory features of the aversive event itself. We investigated this selectivity using cell type-specific imaging and inactivation in hippocampal area CA1 of behaving mice. Aversive stimuli activated CA1 dendrite-targeting interneurons via cholinergic input, leading to inhibition of pyramidal cell distal dendrites receiving aversive sensory excitation from the entorhinal cortex. Inactivating dendrite-targeting interneurons during aversive stimuli increased CA1 pyramidal cell population responses and prevented fear learning. We propose subcortical activation of dendritic inhibition as a mechanism for exclusion of aversive stimuli from hippocampal contextual representations during fear learning.