A defense mechanism is a way for the mind to protect us from being consciously aware of thoughts or feelings that are too difficult to tolerate. Since the thought or feeling is too difficult to tolerate the defense mechanism only allows the unconscious thought or feeling to be expressed indirectly in some type of disguised form. Doing this allows us to reduce anxiety that is caused by the unconscious thought or feeling.
The concept of the defense mechanism was popularized by Freud and the psychoanalytic perspective. There are several different types of defense mechanisms including repression, regression, denial (my personal favorite), projection, compensation, sublimation, reaction formation, rationalization, and hallucination. To find additional information about defense mechanisms go to: http://scholars.nus.edu.sg/landow/victorian/science/freud/defense_mechanisms.htm