We analyze spontaneous pattern formation in a continuum model of primary visual cortex that incorporates spatially periodic inhomogeneities in the distribution of long-range horizontal connections. These inhomogeneities reflect the underlying crystalline-like structure of cortex, as exemplified by the distribution of cytochrome oxidase blobs. We first solve the linear eigenvalue problem for a primary Turing instability, and show how the resulting activity pattern can lock to the underlying cortical lattice when certain resonance conditions are satisfied. This result is then extended to the weakly nonlinear regime by performing a multiple scale perturbation expansion of the nonlocal integro-differential equation that determines cortical activity. The resulting amplitude equation describes the effects of long-wavelength modulations of a primary roll pattern in the presence of periodic inhomogeneities, and is shown to exhibit a commensurate–incommensurate transition analogous to that found in convective fluid systems with external periodic forcing. Extensions of our theory to models of cortical development are briefly discussed.