Temporal lobe epilepsy (TLE) is characterized by debilitating, recurring seizures and an increased risk for cognitive deficits. Mossy cells (MCs) are key neurons in the hippocampal excitatory circuit, and the partial loss of MCs is a major hallmark of TLE. We investigated how MCs contribute to spontaneous ictal activity and to spatial contextual memory in a mouse model of TLE with hippocampal sclerosis, using a combination of optogenetic, electrophysiological, and behavioral approaches. In chronically epileptic mice, real-time optogenetic modulation of MCs during spontaneous hippocampal seizures controlled the progression of activity from an electrographic to convulsive seizure. Decreased MC activity is sufficient to impede encoding of spatial context, recapitulating observed cognitive deficits in chronically epileptic mice.