Ahaṃkāra (अहंकार) is a Sanskrit term that is related to the ego and egoism - that is, the identifying with or attachment to one's ego. The term "ahamkara" comes from an approximately 3,000-year-old Vedic philosophy, where Ahaṃ is the "I" and kāra is "any created thing" or "to do". The term originated in Vedic philosophy over 3,000 years ago, and was later incorporated into Hindu philosophy, particularly Saṃkhyā philosophy.
Ahamkara is one of the four parts of the antahkarana (inner organ) described in Hindu philosophy. The other three parts are Buddhi, Citta and Manas. In the Uttara Mimamsa or vedanta branch of Hindu philosophy, even though it is not discussed in great detail in the Bhagavad Gita, Lord Krishna says to Arjun that ahamkara must be removed - in other words, it should be subordinated to the lord. The reason for this is that the Self is not (cannot be) present when one is in a state of ahamkara.
In Bhagavad Gita Lord Krishna says "Air, water, earth, fire, sky, mind, intelligence and ahankaar (ego) together constitute the nature created by me."
To have an understanding of this term is to have a powerful tool for understanding the nature and behaviour of ourselves and of others. Vedic philosophy teaches that when one's mind is in a state of ahamkara, one is in a state of subjective illusion, where the mind has bound the concept of one's self with an external thing. That thing can be a tangible, material object, or it can be a concept (such as the concept of the fight for peace). The ego is involved in constructing the illusion.
In both cases, the mind has created a state of illusion, but it seems very real to the person in that state, and subjectivity and reality are obscured. This deeply illusory state is what can often cause people to do the strangest, oddest things, sometimes evil, and often quite out of character. All humans can - and usually do at some time in their lives - suffer from this.
Though ahaṃkāra is generally a state of illusion, once in that state, Vak tattva (one of the 36 tattvas) can appear. When it does, then, for the first time, individual will, determination, a sense of morality and ethics come into play - which is the first step on the path to spiritual development/enlightenment. Without a sufficiently harmonious and powerful ahaṃkāra (personality), it is thought to be impossible to exert the level of effort necessary to accede to a higher spiritual level.
The position of ahaṃkāra and buddhi are sometimes presented in reversed order because, as the principle of "I-ness", ahaṃkāra is allowed control over the manas (sensorial mind) and buddhi (superior intellect, intuition). Yet, buddhi is a superior tattva, and ahaṃkāra is thus only able to be in a superior position to buddhi from a functional point of view. From an absolute point of view, ahaṃkāra is created by buddhi and thus subordinate to it.