Heat stroke is a life-threatening condition, characterized by catastrophic collapse of thermoregulation and extreme hyperthermia. In recent years, intensification of heat waves has caused a surge of heat-stroke fatalities. The mechanisms underlying heat-related pathology are poorly understood. Here we show that heat stroke triggers pervasive necrotic cell death and neurodegeneration in Caenorhabditis elegans. Preconditioning of animals at a mildly elevated temperature strongly protects from heat-induced necrosis. The heat-shock transcription factor HSF-1 and the small heat-shock protein HSP-16.1 mediate cytoprotection by preconditioning. HSP-16.1 localizes to the Golgi, where it functions with the Ca(2+)- and Mn(2+)-transporting ATPase PMR-1 to maintain Ca(2+) homeostasis under heat stroke. Preconditioning also suppresses cell death inflicted by diverse insults, and protects mammalian neurons from heat cytotoxicity. These findings reveal an evolutionarily conserved mechanism that defends against diverse necrotic stimuli, and may be relevant to heat stroke and other pathological conditions involving necrosis in humans.