Self-awareness is the capacity for introspection and the ability to recognize oneself as an individual separate from the environment and other individuals. It is not to be confused with consciousness in the sense of qualia. While consciousness is a term given to being aware of one's environment and body and lifestyle, self-awareness is the recognition of that awareness.
There are questions regarding what part of the brain allows us to be self-aware and how we are biologically programmed to be self-aware. V.S. Ramachandran has speculated that mirror neurons may provide the neurological basis of human self-awareness. In an essay written for the Edge Foundation in 2009 Ramachandran gave the following explanation of his theory: "... I also speculated that these neurons can not only help simulate other people's behavior but can be turned 'inward'—as it were—to create second-order representations or meta-representations of your own earlier brain processes. This could be the neural basis of introspection, and of the reciprocity of self awareness and other awareness. There is obviously a chicken-or-egg question here as to which evolved first, but... The main point is that the two co-evolved, mutually enriching each other to create the mature representation of self that characterizes modern humans."
Studies have been done mainly on primates to test if self-awareness is present. Apes, monkeys, elephants, and dolphins have been studied most frequently. The most relevant studies to this day that represent self-awareness in animals have been done on chimpanzees, dolphins, and magpies. Self-awareness in animals is tested through mirror self recognition. Animals who show mirror self recognition go through four stages 1) social response, 2) physical mirror inspection, 3) repetitive mirror testing behavior, and 4) the mark test; which involves the animals spontaneously touching a mark on their body which would have been difficult to see without the mirror.