The striatum is the main input nucleus of the basal ganglia and is a key site of sensorimotor integration. While the striatum receives extensive excitatory afferents from the cerebral cortex, the influence of different cortical areas on striatal circuitry and behavior is unknown. Here we find that corticostriatal inputs from whisker-related primary somatosensory (S1) and motor (M1) cortex differentially innervate projection neurons and interneurons in the dorsal striatum, and exert opposing effects on sensory-guided behavior. Optogenetic stimulation of S1-corticostriatal afferents in ex vivo recordings produced larger postsynaptic potentials in striatal parvalbumin (PV)-expressing interneurons than D1- or D2-expressing spiny projection neurons (SPNs), an effect not observed for M1-corticostriatal afferents. Critically, in vivo optogenetic stimulation of S1-corticostriatal afferents produced task-specific behavioral inhibition, which was bidirectionally modulated by striatal PV-expressing interneurons. M1 input produced the opposite behavioral effect. Thus, our results reveal opposing roles for sensory and motor cortex in behavioral choice via distinct influences on striatal circuitry.