SummaryGamma oscillations are believed to underlie cognitive processes by shaping the formation of transient neuronal partnerships on a millisecond scale. These oscillations are coupled to the phase of breathing cycles in several brain areas, possibly reflecting local computations driven by sensory inputs sampled at each breath. Here, we investigated the mechanisms and functions of gamma oscillations in the piriform (olfactory) cortex of awake mice to understand their dependence on breathing and how they relate to local spiking activity. Mechanistically, we find that respiration drives gamma oscillations in the piriform cortex, which are inhibitory and result from recurrent connections between local excitatory and inhibitory neuronal populations. Moreover, respiration-driven inhibitory gamma oscillations are triggered by the activation of mitral/tufted cells in the olfactory bulb and are abolished during anesthesia. Functionally, we demonstrate that they locally segregate neuronal assemblies through a winner-take-all computation leading to sparse odor coding during each breathing cycle. Our results shed new light on the mechanisms of gamma oscillations, bridging computation, cognition and physiology.