Optogenetic control of the peripheral nervous system (PNS) would enable novel studies of motor control, somatosensory transduction, and pain processing. Such control requires the development of methods to deliver opsins and light to targeted sub-populations of neurons within peripheral nerves. We report here methods to deliver opsins and light to targeted peripheral neurons and robust optogenetic modulation of motor neuron activity in freely moving, non-transgenic mammals. We show that intramuscular injection of adeno-associated virus serotype 6 enables expression of channelrhodopsin (ChR2) in motor neurons innervating the injected muscle. Illumination of nerves containing mixed populations of axons from these targeted neurons and from neurons innervating other muscles produces ChR2-mediated optogenetic activation restricted to the injected muscle. We demonstrate that an implanted optical nerve cuff is well-tolerated, delivers light to the sciatic nerve, and optically stimulates muscle in freely moving rats. These methods can be broadly applied to study PNS disorders and lay the groundwork for future therapeutic application of optogenetics.