This article describes the fabrication and use of microfluidic devices for investigating spatial orientation behaviors in nematode worms (Caenorhabditis elegans). Until now, spatial orientation has been studied in freely moving nematodes in which the frequency and nature of encounters with the gradient are uncontrolled experimental variables. In the new devices, the nematode is held in place by a restraint that aligns the longitudinal axis of the body with the border between two laminar fluid streams, leaving the animal's head and tail free to move. The content of the fluid streams can be manipulated to deliver step gradients in space or time. We demonstrate the utility of the device by identifying previously uncharacterized aspects of the behavioral mechanisms underlying chemotaxis, osmotic avoidance, and thermotaxis in this organism. The new devices are readily adaptable to behavioral and imaging studies involving fluid borne stimuli in a wide range of sensory modalities.