Islamic Roots of Sigmund Freud's Psychoanalytical Theory
Human Soul - Modern Psychology calls it Psyche, Islam divides it in to Nafs (Evil Commanding Soul) and Ruh (Spirit or Upper Soul). Allah ﷻ created this for our intellectual and spiritual progress, which ultimately fulfills the purpose of our existence. Modern psychology divides Psyche in to three parts as per Psychoanalytical Theory of Sigmund Freud. The following analysis proves Islamic roots of Freudan Theory:
Id – Ego – Superego
Dr. Israr Ahmad, 21st century Islamic scholar, theologian and philosopher compares the Id - Ego - Superego to Islamic concepts of Nafs - Qalb (The Heart) – Ruh. The explanation under each is interestingly also found, with much details, in the classical work called Ihya Ulum id-deen of Imam Ghazali.
Id - Demands immediate satisfaction of its desires to fulfill its bodily needs/wants of food/sexual drive or whatever desires occur from it. Dr. Israr refers to Nafs as the primal instinct just like the Id is hedonistic; it seeks pleasure. Imam Ghazali calls it passion carrying evil attributes such as anger, greed, jealousy etc. Struggle (jihad) against its tendencies is called greater struggle (jihad al-akbar) in Islam. As per Al Quran 12:53 unrestrained obedience to it results in soul taking the form of Nafse Amara Bissu (Evil Commanding Soul).
Ego - Judgmental before action and intervenes between the Id and its object of satisfaction. It works based on reality principle i.e. analyzes external factors and their impact to prevent psyche from blindly following desires of Id. The Qalb (heart) according to Dr. Israr is like Ego, in a perpetual state of change, pulled by Nafs on one side and Ruh on the other. Imam Ghazali says with Qalb we also carry Aql (Intellect), situated in the Soul, whose content and attribute are Knowledge and Will, which determine the result of our choices and actions whether good or bad, then either accepts them or rejects. Altogether, Qalb and Aql are equivalent to Freudian's Ego. When Soul remains imperfect, continues to correct itself when wrong or accuse itself every time it disobeys, it takes the form of Nafse Luwwamah (the [self-] reproaching soul) as per Al Quran 75:02.
Superego - The Super-ego is the moral component of the psyche according to Freud. It contains internalized societal and parental standards of “good”, “bad”, “right” and “wrong” behavior we learn consciously or unconsciously. According to Ghazali this is Fitrah (Nature) referring to prophetic hadith that states: "No child is born except on Al-Fitra (Islam) and then his parents make him Jewish, Christian or Magian." Implying upbringing forms our character, influencing our decisions and outlook later in life. This is equivalent to Superego of Freudian Theory which assists the Ego in restraining Id but the restraining influence depends on upbringing factors. The Imam claims that restraining influence comes when soul gains spiritual power and knowledge through inspiration (ilhaam) as well through learning & efforts. He says continuous opposition of the lower tendencies of the Nafs removes passion, adopts angelic nature of Ruh (upper soul), assumes calmness and becomes Nafse Mutmainna (soul at peace) as per Al Quran 89:27.
Similarity of Ghazali's analogy on controlling Nafs with Sigmund Freud's analogy of controlling Id.
Imam Ghazali says, “Intellect is like a rider, greed like a horse and anger like hunting dog. When rider (Aql) is expert and his horse and dog (Nafs) are trained, success can be obtained in hunting. When rider is inexperienced, horse disobedient and dog biting then they do not obey him”
Sigmund Freud provides a similar analogy explaining struggle between Id and Ego: “Thus in its relation to the Id, Ego is like a man on horseback, who has to hold in check the superior strength of the horse; with this difference, that the rider tries to do so with his own strength while the Ego uses borrowed forces. Often a rider, if he is not to be parted from his horse, is obliged to guide it where it wants to go; so in the same way the Ego is in the habit of transforming the Id's will into action as if it were its own.”
 Abu Ḥamid Muḥammad ibn Muḥammad aṭ-Ṭusi al-Ġazali; latinized Algazel; (CE 1058 – 1111). One of the very renowned scholar, jurist, philosopher, mystic of Islam.
CHAPTER I - Soul and its attributes - Ghazzali 1993
 Psychoanalysis - University 2003