For many organisms the ability to transduce light into cellular signals is crucial for survival. Light stimulates DNA repair and metabolism changes in bacteria, avoidance responses in single-cell organisms, attraction responses in plants, and both visual and nonvisual perception in animals. Despite these widely differing responses, in all of nature there are only six known families of proteins that can transduce light. Although the roundworm Caenorhabditis elegans has none of the known light transduction systems, we show here that C. elegans strongly accelerates its locomotion in response to blue or shorter wavelengths of light, with maximal responsiveness to ultraviolet light. Our data suggest that C. elegans uses this light response to escape the lethal doses of sunlight that permeate its habitat. Short-wavelength light drives locomotion by bypassing two critical signals, cyclic adenosine monophosphate (cAMP) and diacylglycerol (DAG), that neurons use to shape and control behaviors. C. elegans mutants lacking these signals are paralyzed and unresponsive to harsh physical stimuli in ambient light, but short-wavelength light rapidly rescues their paralysis and restores normal levels of coordinated locomotion. This light response is mediated by LITE-1, a novel ultraviolet light receptor that acts in neurons and is a member of the invertebrate Gustatory receptor (Gr) family. Heterologous expression of the receptor in muscle cells is sufficient to confer light responsiveness on cells that are normally unresponsive to light. Our results reveal a novel molecular solution for ultraviolet light detection and an unusual sensory modality in C. elegans that is unlike any previously described light response in any organism.