A mechanism of attention is proposed according to which its influence on visual processing is switched on by release of dopamine into the striatum. A dopamine release during involuntary attention is promoted by visual activation of striatonigral cells via the thalamus and subsequent disinhibition through the basal ganglia of the superior colliculus. A dopamine release during voluntary attention is promoted by activation of prefrontal cortex. The strengthening of responses of neocortical neurons to attended stimulus, and suppression of responses to other stimuli is the result of opposite modulatory action of dopamine on the efficacy of strong and weak corticostriatal inputs. This leads to changes in the output basal ganglia signals ("attentional filter") that exert disinhibitory and inhibitory influence (via the thalamus) on neocortical cells that initially were strongly and weakly activated by a stimulus, respectively. From proposed mechanism follows, that attention modulates only those components of responses of cortical neurons which latency exceeds the latency of reactions of dopaminergic cells (80-100 ms).