Supernova explosions in the early star forming galaxies will accelerate cosmic rays (CRs). CRs are typically confined in the collapsed objects for a short period before escaping into the intergalactic medium (IGM). Galactic outflows can facilitate this escape by advecting CRs into the IGM. An outflow that results in a termination shock can also generate more CRs. We show that the CR protons from the above processes can significantly affect the thermal history of the IGM. Within plausible range of parameters, cosmic ray heating can compensate for adiabatic cooling and explain the measured IGM temperature at redshifts z between 2 to 4, even with early reionization.