For studying the function of specific neurons in their native circuitry, it is desired to precisely control their activity. This often requires dissection to allow accurate electrical stimulation or neurotransmitter application , and it is thus inherently difficult in live animals, especially in small model organisms. Here, we employed channelrhodopsin-2 (ChR2), a directly light-gated cation channel from the green alga Chlamydomonas reinhardtii, in excitable cells of the nematode Caenorhabditis elegans, to trigger specific behaviors, simply by illumination. Channelrhodopsins are 7-transmembrane-helix proteins that resemble the light-driven proton pump bacteriorhodopsin , and they also utilize the chromophore all-trans retinal, but to open an intrinsic cation pore. In muscle cells, light-activated ChR2 evoked strong, simultaneous contractions, which were reduced in the background of mutated L-type, voltage-gated Ca2+-channels (VGCCs) and ryanodine receptors (RyRs). Electrophysiological analysis demonstrated rapid inward currents that persisted as long as the illumination. When ChR2 was expressed in mechanosensory neurons, light evoked withdrawal behaviors that are normally elicited by mechanical stimulation. Furthermore, ChR2 enabled activity of these neurons in mutants lacking the MEC-4/MEC-10 mechanosensory ion channel . Thus, specific neurons or muscles expressing ChR2 can be quickly and reversibly activated by light in live and behaving, as well as dissected, animals.