Allah T'ala says in the Holy Quran:
وَإِذْ قَالَ إِبْرَاهِيمُ لأَبِيهِ آزَرَ أَتَتَّخِذُ أَصْنَامًا آلِهَةً إِنِّي أَرَاكَ وَقَوْمَكَ فِي ضَلاَلٍ مُّبِينٍ
وَكَذَلِكَ نُرِي إِبْرَاهِيمَ مَلَكُوتَ السَّمَاوَاتِ وَالأَرْضِ وَلِيَكُونَ مِنَ الْمُوقِنِينَ
فَلَمَّا جَنَّ عَلَيْهِ اللَّيْلُ رَأَى كَوْكَبًا قَالَ هَـذَا رَبِّي فَلَمَّا أَفَلَ قَالَ لا أُحِبُّ الآفِلِينَ
فَلَمَّا رَأَى الْقَمَرَ بَازِغًا قَالَ هَـذَا رَبِّي فَلَمَّا أَفَلَ قَالَ لَئِن لَّمْ يَهْدِنِي رَبِّي لأكُونَنَّ مِنَ الْقَوْمِ الضَّالِّينَ
فَلَمَّا رَأَى الشَّمْسَ بَازِغَةً قَالَ هَـذَا رَبِّي هَـذَآ أَكْبَرُ فَلَمَّا أَفَلَتْ قَالَ يَا قَوْمِ إِنِّي بَرِيءٌ مِّمَّا تُشْرِكُونَ
إِنِّي وَجَّهْتُ وَجْهِيَ لِلَّذِي فَطَرَ السَّمَاوَاتِ وَالأَرْضَ حَنِيفًا وَمَا أَنَاْ مِنَ الْمُشْرِكِينَ
006.074 Lo! Abraham said to his father Azar: "Takest thou idols for gods? For I see
thee and thy people in manifest error."
006.075 So also did We show Abraham the power and the laws of the heavens and
the earth, that he might (with understanding) have certitude.
006.076 When the night covered him over, He saw a star: He said: "This is my
Lord." But when it set, He said: "I love not those that set."
006.077 When he saw the moon rising in splendour, he said: "This is my Lord." But
when the moon set, He said: "unless my Lord guide me, I shall surely be among those
who go astray."
006.078 When he saw the sun rising in splendour, he said: "This is my Lord; this is
the greatest (of all)." But when the sun set, he said: "O my people! I am indeed free
from your (guilt) of giving partners to God.
006.079 "For me, I have set my face, firmly and truly, towards Him Who created the
heavens and the earth, and never shall I give partners to God."
In these verses, some light is thrown on the mental experience through which Abraham (peace be on him) passed in the beginning and which led him to an understanding of the Truth before prophethood was bestowed on him. This experience shows how a right-thinking and sound-hearted man, who had opened his eyes in a purely polytheistic environment and had received no instruction in monotheism, was ultimately led to discover the Truth by careful observation of, and serious reflection on the phenomena of the universe.
The account of the conditions prevailing among the people of Abraham shows that when he began to think seriously, the scene was dominated by the worship of the heavenly bodies - the moon, the sun and the stars. It was natural, therefore, that when Abraham began his quest for the Truth, he should have been faced with the question: Is it possible that any of these, the sun, the moon and the stars, is God? He concentrated his reflection on this central question and by observing that all the gods of his nation were bound by a rigid law under which they moved about like slaves, he concluded that those so-called gods were not possessed of even a shadow of the power of the One True Lord, Who alone had created them all and had yoked them to serve His will.
The Qur'anic passage describing Abraham's reactions on observing first a star, then the moon, and finally the sun, has puzzled some readers because the words seem to suggest that Abraham had never before witnessed these common phenomena. This misconception has made the whole narration such a riddle for some scholars that they could only solve it by inventing the strange anecdote that Abraham was born and grew to maturity in a cave and was thus deprived of the opportunity to observe the heavenly bodies. What is said, however, is so plain that one need not fall back on any such incident in order to comprehend it. It is well known, for instance, that when Newton saw an apple fall from a tree in his orchard, the incident instantly raised in his mind the question: Why do things always fall to the ground? As a result of his reflection on this question he arrived at his theory of gravity. On reading this incident one might wonder if Newton had never before seen anything fall to the ground! Obviously, he must have seen things fall. For what reason, then, should the falling of an apple cause in his mind a reaction quite different from those caused by hundreds of earlier observations of similar things falling? The answer is that a reflecting mind does not react uniformly to similar observations. A man may observe something over and over again without this observation creating any stir in his mind, but then there comes a moment when suddenly the same observation agitates his mind and his mental faculty begins to work in a different direction. It may also happen that while a man's mind is wrestling with a problem, he encounters something which is otherwise quite ordinary but which suddenly seems to provide the key. Something to this effect happened with Abraham. Certainly, he was as familiar as anyone else with nightfall and the ensuing daybreak. The sun, the moon and the stars had all risen before his eyes in the past and had then disappeared from sight. But on one particular day his observation of a star was to stimulate his thinking in a certain direction and to lead him in the end to perceive the truth of God's Oneness. It is possible that Abraham's mind was already engrossed in reflecting on whether, and if so to what extent, the beliefs which served as the foundation of the entire life-system of his people embodied the Truth. when he spotted a star which provided him with the initial key to the solution of the problem. It is also possible that the observation of a particular star first set him thinking about the problem.
Another question that arises is whether Abraham's statements about the star, the moon and the sun show that he lapsed into polytheism temporarily. The answer must be that, while a seeker after the Truth may pause on the way to his goal, what really matters is his direction and the end-point of his journey rather than the intermediary stages. These stages are inevitable for every seeker of the Truth. A man stops at them to inquire and question rather than to pronounce his final judgement. During these stages of the quest a man may seem to express the opinion: 'That is so', but what he is really doing is asking himself the question: 'Is it really so?' When serious investigation leads to a negative answer, he proceeds further and continues the quest. Hence, it would be wrong to think of such a seeker having temporarily fallen victim to polytheism and unbelief whenever he paused at an intermediary stage for critical reflection.