The rodent primary somatosensory cortex is spontaneously active in the form of locally synchronous membrane depolarizations (UP states) separated by quiescent hyperpolarized periods (DOWN states) both under anesthesia and during quiet wakefulness. In vivo whole-cell recordings and tetrode unit recordings were combined with voltage-sensitive dye imaging to analyze the relationship of the activity of individual pyramidal neurons in layer 2/3 to the ensemble spatiotemporal dynamics of the spontaneous depolarizations. These were either brief and localized to an area of a barrel column or occurred as propagating waves dependent on local glutamatergic synaptic transmission in layer 2/3. Spontaneous activity inhibited the sensory responses evoked by whisker deflection, accounting almost entirely for the large trial-to-trial variability of sensory-evoked postsynaptic potentials and action potentials. Subthreshold sensory synaptic responses evoked while a cortical area was spontaneously depolarized were smaller, briefer and spatially more confined. Surprisingly, whisker deflections evoked fewer action potentials during the spontaneous depolarizations despite neurons being closer to threshold. The ongoing spontaneous activity thus regulates the amplitude and the time-dependent spread of the sensory response in layer 2/3 barrel cortex.