The ability to encode rules and to detect rule-violating events outside the focus of attention is vital for adaptive behavior. Our brain recordings reveal that violations of abstract auditory rules are processed even when the sounds are unattended. When subjects performed a task related to the sounds but not to the rule, rule violations impaired task performance and activated a network involving supratemporal, parietal and frontal areas although none of the subjects acquired explicit knowledge of the rule or became aware of rule violations. When subjects tried to behaviorally detect rule violations, the brain's automatic violation detection facilitated intentional detection. This shows the brain's capacity for abstraction - an important cognitive function necessary to model the world. Our study provides the first evidence for the task-independence (i.e. automaticity) of this ability to encode abstract rules and for its immediate consequences for subsequent mental processes.