Expression of halorhodopsin (NpHR), a light-driven microbial chloride pump, enables optical control of membrane potential and reversible silencing of targeted neurons. We generated transgenic zebrafish expressing enhanced NpHR under control of the Gal4/UAS system. Electrophysiological recordings showed that eNpHR stimulation effectively suppressed spiking of single neurons in vivo. Applying light through thin optic fibers positioned above the head of a semi-restrained zebrafish larva enabled us to target groups of neurons and to simultaneously test the effect of their silencing on behavior. The photostimulated volume of the zebrafish brain could be marked by subsequent photoconversion of co-expressed Kaede or Dendra. These techniques were used to localize swim command circuitry to a small hindbrain region, just rostral to the commissura infima Halleri. The kinetics of the hindbrain-generated swim command was investigated by combined and separate photo-activation of NpHR and Channelrhodopsin-2 (ChR2), a light-gated cation channel, in the same neurons. Together this "optogenetic toolkit" allows loss-of-function and gain-of-function analyses of neural circuitry at high spatial and temporal resolution in a behaving vertebrate.