We model the development of the functional circuit of layer 4 (the input-recipient layer) of cat primary visual cortex. The observed thalamocortical and intracortical circuitry codevelop under Hebb-like synaptic plasticity. Hebbian development yields opponent inhibition: inhibition evoked by stimuli anticorrelated with those that excite a cell. Strong opponent inhibition enables recognition of stimulus orientation in a manner invariant to stimulus contrast. These principles may apply to cortex more generally: Hebb-like plasticity can guide layer 4 of any piece of cortex to create opposition between anticorrelated stimulus pairs, and this enables recognition of specific stimulus patterns in a manner invariant to stimulus magnitude. Properties that are invariant across a cortical column are predicted to be those shared by opponent stimulus pairs; this contrasts with the common idea that a column represents cells with similar response properties.