It is only in recent times that it has been defined in psychological terms.
In 1899, Paul Näche was the first person to use the term "narcissism" in a study of sexual perversions.
The name "narcissism" is derived the from the Greek mythology of Narcissus. Narcissus was a handsome Greek youth who rejected the desperate advances of the nymph Echo. As punishment, he was doomed to fall in love with his own reflection in a pool of water. Unable to consummate his love, Narcissus pined away and changed into a flower that bears his name, the narcissus.
Freud suggested that exclusive self-love might not be as abnormal as previously thought and might even be a common component in the human psyche. He argued that narcissism "is the libidinal complement to the egoism of the instinct of self-preservation," or, more simply, the desire and energy that drives one’s instinct to survive. He referred to this as primary narcissism. 
According to Freud, people are born without a sense of themselves as individuals, or ego. The ego develops during infancy and the early part of childhood, only when the outside world, usually in the form of parental controls and expectations, intrudes upon primary narcissism, teaching the individual about the nature and standards of his social environment from which he can form the ideal ego, an image of the perfect self towards which the ego should aspire.
Freud regarded all libidinous drives as fundamentally sexual and suggested that ego libido (libido directed inwards to the self) cannot always be clearly distinguished from object-libido (libido directed to persons or objects outside oneself).
An aspect frequently associated with primary narcissism appears in an earlier essay, 'Totem and Taboo,' in which Freud describes his observations of children and primitive people. What he observed was called magical thinking, such as the belief that a person can impact reality by wishing or willpower. It demonstrates a belief in the self as powerful and able to change external realities, which Freud believed was part of normal human development.
According to Freud, secondary narcissism is a pathological condition that occurs when the libido withdraws from objects outside the self. Freud further claimed that it is an extreme form of the narcissism that is part of all people.
According to Freud, to care for someone is to convert ego-libido into object-libido by giving some self-love to another person, which leaves less ego-libido available for primary narcissism and protecting and nurturing the self. When that affection is returned so is the libido, thus restoring primary narcissism and self worth. Any failure to achieve, or disruption of, this balance causes psychological disturbances. In such a case, primary narcissism can be restored only by withdrawing object-libido (also called object-love) to replenish ego-libido.
According to Freud, as a child grows, and his ego develops, he is constantly giving of his self-love to people and objects, the first of which is usually his mother. This diminished self-love should be replenished by the affection and caring returned to him.
Karen Horney saw narcissism quite differently from Freud, Kohut and other mainstream psychoanalytic theorists in that she did not posit a primary narcissism but saw the narcissistic personality as the product of a certain kind of early environment acting on a certain kind of temperament. For her, narcissistic needs and tendencies are not inherent in human nature.
Narcissism is different from Horney's other major defensive strategies or solutions in that it is not compensatory. Self-idealization is compensatory in her theory, but it differs from narcissism. All the defensive strategies involve self-idealization, but in the narcissistic solution it tends to be the product of indulgence rather than of deprivation. The narcissist's self-esteem is not strong, however, because it is not based on genuine accomplishments.
Heinz Kohut explored further the implications of Freud's perception of narcissism. He maintained that a child will tend to fantasize about having a grandiose self and ideal parents. He claimed that deep down, all people retain a belief in their own perfection and the perfection of anything of which they are a part. As a person matures, grandiosity gives way to self-esteem, and the idealization of the parent becomes the framework for core values. It is when psychological trauma disrupts this process that the most primitive and narcissistic version of the self remains unchanged. Kohut called this condition narcissistic personality disorder.
Kohut suggested narcissism as part of a stage in normal development, in which caregivers provide a strong and protective presence with which the child can identify that reinforces the child's growing sense of self by mirroring his good qualities. If the caregivers fail to provide adequately for their child, the child grows up with a brittle and flawed sense of self.
He also saw beyond the negative and pathological aspects of narcissism, believing it to be a component in the development of resilience, ideals and ambition once it has been transformed by life experiences or analysis.
He regarded normal, infantile narcissism to be dependent on the affirmation of others and the acquisition of desirable and appealing objects, which should later develop into healthy, mature self-esteem. This healthy narcissism depends upon an integrated sense of self that incorporates images of the internalized affirmation of those close to the person and is regulated by the super ego and ego ideal, internal mental structures that assure the person of his worth and that he deserves his own respect.