Recent neurophysiological studies have shown that primary visual cortex, or V1, does more than passively process image features using the feedforward filters suggested by Hubel and Wiesel. It also uses horizontal interactions to group features preattentively into object representations, and feedback interactions to selectively attend to these groupings. All neocortical areas, including V1, are organized into layered circuits. We present a neural model showing how the layered circuits in areas V1 and V2 enable feedforward, horizontal, and feedback interactions to complete perceptual groupings over positions that do not receive contrastive visual inputs, even while attention can only modulate or prime positions that do not receive such inputs. Recent neurophysiological data about how grouping and attention occur and interact in V1 are simulated and explained, and testable predictions are made. These simulations show how attention can selectively propagate along an object grouping and protect it from competitive masking, and how contextual stimuli can enhance or suppress groupings in a contrast-sensitive manner.