A defense mechanism is a set of actions, thought patterns, and attitudes that people use to separate themselves from upsetting thoughts, events, or actions. The human brain uses these psychological strategies to keep away from unwanted emotions and threats such as guilt and shame.