The ego can be a positive image of oneself or a negative one. Usually, it includes both positive and negative aspects. The ego contains the individual's sense of self-worth, self-confidence and self-esteem. It has desires -- such as wealth, prestige and success.
A related term, egoism (asmita) denotes an attachment to whatever the ego wants. It is this attachment that prevents samadhi, or the state of bliss and oneness with the Divine. Attachment to the ego is one of the five obstacles, or kleshas, that sage Patanjali mentions in the Yoga Sutras.
One of the goals of yoga practice is the removal of these obstacles so that the practitioner may experience samadhi. For example, in asana practice, the ego may desire to perform a pose perfectly or to compete with others to be the best. Acknowledging this desire and acting on it is egoism. Instead, the yoga practioner should look inward and examine the needs of the body and the Self, then focus on that instead.
Through non-ego-driven asana practice, opening the chakras, meditation and pranayama breathing, one can clear the mind and detach from the ego. From this state, the wants and needs of the ego can be observed without judgment or attachment and the practitioner can gain a truer sense of the Self.