Revelation of the Quran: All at Once or Gradually?
Question

Some opinions suggest that the Quran was revealed in a single night, and some say that the Quran was revealed over several years in Makkah and Madinah. Do these opinions contradict one another? Is one right and the other wrong? Or are they both wrong?
Praise be to Allah.Did the Quran come down all at once?
The issue mentioned has two aspects: on one there is consensus and the other is a matter in which there are differences of opinion. 
With regard to the aspect on which there is consensus, it is that the Quran did not come down from Heaven to the Messenger of Allah (peace and blessings of Allah be upon him) all at once; rather the Revelation came down to him from Allah piecemeal, according to events and circumstances. 
There are verses which confirm this quite clearly with no confusion, and they affirm the wisdom behind its being revealed in this manner: 
1- Allah, may He be exalted, says (interpretation of the meaning):
“And those who disbelieve say: Why is not the Quran revealed to him all at once? Thus (it is sent down in parts), that We may strengthen your heart thereby. And We have revealed it to you gradually, in stages.” [25:32] 
Shaykh ‘Abd ar-Rahman as-S’adi (may Allah have mercy on him) said: 
“That is because every time something of the Quran was revealed to him, it increased his certainty and steadfastness, especially when there was cause for anxiety. The fact that the Quran was revealed when new developments occurred meant that it had greater impact and was more reassuring to the Prophet (peace and blessings of Allah be upon him). And that was more effective than if it had been revealed before that, then was remembered when the new developments occurred.  
“And We have revealed it to you gradually, in stages,” means We revealed it slowly and sent it gradually. All of this indicates that Allah was taking care of His Book, the Quran, and His Messenger, Muhammad (peace and blessings of Allah be upon him), as He sent down His Book in accordance with the situations faced by the Messenger and as needed to address unfolding issues.” (Tafsir as-S’adi)
2- Allah, may He be exalted, says (interpretation of the meaning) says:
“And (it is) a Quran which We have divided (into parts), in order that you might recite it to men at intervals. And We have revealed it by stages.” [17:106] 
Shaykh ‘Abd ar-Rahman as-S’adi (may Allah have mercy on him) said: 
“At intervals” means at an easy pace, so that they might ponder it and think about its meanings, and derive knowledge from it. 
“And We have revealed it by stages,” means: bit by bit, piecemeal over twenty-three years.” (Tafsir as- S’adi)
The Quran was revealed piecemeal 
What confirms the fact that the Quran was revealed piecemeal is the suspension of the Revelation concerning the slander incident (al-ifk), in which ‘Aishah (may Allah be pleased with her) was accused of adultery. The Prophet (peace and blessings of Allah be upon him) was waiting for Quranic verses to be revealed, because of the enormity of the calamity and the accusation that was made against his wife, until the words of Allah were revealed (interpretation of the meaning):
“Verily! Those who brought forth the slander (against ‘Aishah, the wife of the Prophet (peace and blessings of Allah be upon him)) are a group among you. Consider it not a bad thing for you. Nay, it is good for you. Unto every man among them will be paid that which he had earned of the sin, and as for him among them who had the greater share therein, his will be a great torment.” [24:11] 
Another confirmation that the Quran was revealed piecemeal is the first few verses of Surah ‘Abasa which were revealed when the Prophet (peace and blessings of Allah be upon him) turned away from teaching the blind man Ibn Umm Maktum  (may Allah be pleased with him) in the hope that the leaders of Quraysh would become Muslim (as he was already talking to the leaders of Quraysh and the blind mind man came to him in the middle of the conversation). 
How was the start of the revelation of the Quran?
With regard to that concerning which there is a difference of opinion, it has to do with the start of the revelation of the Quran . Was it sent down all at once to the first heaven, then brought down to the Messenger (peace and blessings of Allah be upon him) piecemeal, or was it all brought down in the same manner, piecemeal according to events, as stated above? 
The reason for this difference of opinion is differences in understanding some verses which indicate that the Quran came down at a particular time, such as the verses in which Allah says (interpretation of the meaning):
“The month of Ramadan in which was revealed the Quran, a guidance for mankind and clear proofs for the guidance and the criterion (between right and wrong).” [2:185]
“Verily! We have sent it (this Quran) down on the night of Al-Qadr (Decree).” [97:1]
And Ibn ‘Abbas (may Allah be pleased with him) clearly stated this understanding. 
The scholars differed concerning this sending down; there are several opinions, the most well-known of which are two: 
1- The view of the majority is that the Quran was sent down from al-Lawh al-Mahfuz (the Preserved Tablet) to the first heaven on Laylat al-Qadr (the night of Decree) all at once, then after that it was sent down in stages over twenty-three years. 
It was narrated that Ibn ‘Abbas  (may Allah be pleased with him) said, concerning the verse “Verily! We have sent it (this Quran) down on the night of Al-Qadr (Decree).” The Quran was sent down all at once on Laylat al-Qadr, then Allah sent it down to the Messenger of Allah (peace and blessings of Allah be upon him) bit by bit. “And those who disbelieve say: Why is not the Quran revealed to him all at once? Thus (it is sent down in parts), that We may strengthen your heart thereby. And We have revealed it to you gradually, in stages.” [25:32]. [an-Nasai]
2- The second opinion is that the revelation of the Quran began on Laylat al-Qadr, then after that it was revealed in stages at various times, according to the unfolding of events and what the people needed. This is the view of the great Tabi‘i (Successor) ash-Sh’abi. 
This difference of opinion – as you can see – does not have any real impact on the reality of the revelation of the Quran in stages to the Prophet (peace and blessings of Allah be upon him). It has been said that the reason for this revelation (being sent down all at once to the first heaven) was to highlight the nobility and great status of the Quran in the upper realm (the heavens). 
Badr ad-Din az-Zarkashi (may Allah have mercy on him) said: 
“If it is asked: what is the reason for the Quran being sent down to the first heaven all at once? The answer is to highlight its high status and the high status of the one to whom it was revealed. That was so as to announce to the inhabitants of the seven heavens that this was the last of the Books that was being sent down to the last of the Messengers and to the noblest of the nations.” (Al-Burhan fi ‘Ulum al-Quran)
How was the Quran conveyed to Prophet Muhammad?
The Angel of Revelation who brought it down to the Prophet (peace and blessings of Allah be upon him), Jibril (peace be upon him), only heard it from the Lord of Glory, may He be exalted, then he passed it on to the Prophet (peace and blessings of Allah be upon him), so he heard it with his ears and his heart understood it. Allah, may He be exalted, says (interpretation of the meaning):
“And verily, you (O Muhammad (peace and blessings of Allah be upon him)) are receiving the Quran from the One, All-Wise, All-Knowing.” [27:6]
“And if you do not bring them a miracle (according to their (i.e. Quraysh-pagans) proposal), they say: Why have you not brought it? Say: I but follow what is revealed to me from my Lord.” [7: 203] 
‘Abdullah ibn Mas‘ud (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings of Allah be upon him) said: “When Allah speaks via revelation, the people of heaven hear from heaven a clanging like a chain dragged across a rock and they swoon, then they remain like that until Jibril (peace be upon him) comes to them. When he comes to them, they recover and say: O Jibril, what did your Lord say? He says: The truth, and they say: The truth, the truth.” [Abu Dawud]
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
“The fact that it – the Quran – is written in al-Lawh al-Mahfuz and in pure pages in the hands of the angels does not contradict the idea that Jibril (peace be upon him) brought it down from Allah, whether Allah wrote it down before sending Jibril (peace be upon him) with it or after that. And if He sent it down written to Bayt al-‘Izzah (in the first heaven) in one go on Laylat al-Qadr, then He had written it all before sending it down. … If anyone says that Jibril (peace be upon him) took the Quran from the Book and did not hear it from Allah, this is false for a number of reasons – which the author then listed.” (Majmu‘ al-Fatawa) 
We hope that this is sufficiently clear and we hope that you will remain in contact with us if you have any further questions about this matter or if you need to ask more questions about any matter of our religion. We ask Allah to help you and guide you to that which is in your best interests in this world and in the Hereafter. 
And Allah knows best.