Neuronal dendrites are electrically excitable: they can generate regenerative events such as dendritic spikes in response to sufficiently strong synaptic input. Although such events have been observed in many neuronal types, it is not well understood how active dendrites contribute to the tuning of neuronal output in vivo. Here we show that dendritic spikes increase the selectivity of neuronal responses to the orientation of a visual stimulus (orientation tuning). We performed direct patch-clamp recordings from the dendrites of pyramidal neurons in the primary visual cortex of lightly anaesthetized and awake mice, during sensory processing. Visual stimulation triggered regenerative local dendritic spikes that were distinct from back-propagating action potentials. These events were orientation tuned and were suppressed by either hyperpolarization of membrane potential or intracellular blockade of NMDA (N-methyl-d-aspartate) receptors. Both of these manipulations also decreased the selectivity of subthreshold orientation tuning measured at the soma, thus linking dendritic regenerative events to somatic orientation tuning. Together, our results suggest that dendritic spikes that are triggered by visual input contribute to a fundamental cortical computation: enhancing orientation selectivity in the visual cortex. Thus, dendritic excitability is an essential component of behaviourally relevant computations in neurons.