In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
The People differ (in their views) concerning earthquakes-some say that it is a natural phenomenon and it has nothing to do with religion; others say that it (occurs) by Allaah’s decision and pre-decree and it has nothing to do with the sins (of the people); and others say that it is warning for (the slaves to fear Allaah’s punishment) and it has nothing to do with (their sins); and others say that it (occurs) as a result of the sins (of the people)?
The answer to this is: It may occur as a warning, a decision and pre-decree of Allaah and as a result of the sins (of the people). Earthquakes can occur as a warning for those who are witness it and are alive. He (The Most High) said:
وَإِنْ مِنْ قَرْيَةٍ إِلَّا نَحْنُ مُهْلِكُوهَا قَبْلَ يَوْمِ الْقِيَامَةِ أَوْ مُعَذِّبُوهَا عَذَابًا شَدِيدًا ۚ كَانَ ذَٰلِكَ فِي الْكِتَابِ مَسْطُورًا
وَمَا مَنَعَنَا أَنْ نُرْسِلَ بِالْآيَاتِ إِلَّا أَنْ كَذَّبَ بِهَا الْأَوَّلُونَ ۚ وَآتَيْنَا ثَمُودَ النَّاقَةَ مُبْصِرَةً فَظَلَمُوا بِهَا ۚ وَمَا نُرْسِلُ بِالْآيَاتِ إِلَّا تَخْوِيفًا
And there is not a town (population) but We shall destroy it before the Day of Resurrection, or punish it with a severe torment. That is written in the Book (of our Decrees); And nothing stops Us from sending the Ayat (proofs, evidences, signs) but that the people of old denied them. And We sent the she-camel to Thamud as a clear sign, but they did her wrong. And We sent not the signs except to warn, and to make them afraid (of destruction).[Soorah Al-Israa: Aayaat:58-59]
As for it being the decision and pre-decree of Allaah, He (The Most High) said:
مَا أَصَابَ مِنْ مُصِيبَةٍ فِي الْأَرْضِ وَلَا فِي أَنْفُسِكُمْ إِلَّا فِي كِتَابٍ مِنْ قَبْلِ أَنْ نَبْرَأَهَا ۚ إِنَّ ذَٰلِكَ عَلَى اللَّهِ يَسِيرٌ
No calamity befalls on the earth or in yourselves but is inscribed in the Book of Decrees (Al-Lauh Al-Mahfuz), before We bring it into existence. Verily, that is easy for Allah”. [Soorah Al-Hadeed: Ayah:22].
And He (The Most High) also said:
مَا أَصَابَ مِنْ مُصِيبَةٍ إِلَّا بِإِذْنِ اللَّهِ ۗ وَمَنْ يُؤْمِنْ بِاللَّهِ يَهْدِ قَلْبَهُ ۚ وَاللَّهُ بِكُلِّ شَيْءٍ عَلِيمٌ
No calamity befalls, but with the Leave [i.e. decision and Qadar (Divine Preordainments)] of Allah, and whosoever believes in Allah, He guides his heart [to the true Faith with certainty, i.e. what has befallen him was already written for him by Allah from the Qadar (Divine Preordainments)], and Allah is the All-Knower of everything.” [Soorah At-Taghaabun: Ayah:11]
As for it being a result of the sins (of the people), Allaah (The Mighty and Majestic) said in His Noble Book:
وَمَا أَصَابَكُمْ مِنْ مُصِيبَةٍ فَبِمَا كَسَبَتْ أَيْدِيكُمْ وَيَعْفُو عَنْ كَثِيرٍ
And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much. [Soorah Ash-Shoorah: Ayah:30]
He (The Most High) said:
ذَٰلِكَ أَنْ لَمْ يَكُنْ رَبُّكَ مُهْلِكَ الْقُرَىٰ بِظُلْمٍ وَأَهْلُهَا غَافِلُونَ
This is because your Lord would not destroy the (populations of) towns for their wrong-doing (i.e. associating others in worship along with Allah) while their people were unaware (so the Messengers were sent).” [Soorah An-An’aam: Ayah: 131]
And He (The Most High) said:
وَمَا كَانَ رَبُّكَ لِيُهْلِكَ الْقُرَىٰ بِظُلْمٍ وَأَهْلُهَا مُصْلِحُونَ
And your Lord would never destroy the towns wrongfully, while their people were right-doers.” [Soorah Hud: Ayah: 117]
And He (The Most High) said:
وَكَمْ أَهْلَكْنَا مِنْ قَرْيَةٍ بَطِرَتْ مَعِيشَتَهَا ۖ فَتِلْكَ مَسَاكِنُهُمْ لَمْ تُسْكَنْ مِنْ بَعْدِهِمْ إِلَّا قَلِيلًا ۖ وَكُنَّا نَحْنُ الْوَارِثِينَ
وَمَا كَانَ رَبُّكَ مُهْلِكَ الْقُرَىٰ حَتَّىٰ يَبْعَثَ فِي أُمِّهَا رَسُولًا يَتْلُو عَلَيْهِمْ آيَاتِنَا ۚ وَمَا كُنَّا مُهْلِكِي الْقُرَىٰ إِلَّا وَأَهْلُهَا ظَالِمُونَ
And how many a town (population) have We destroyed, which were thankless for its means of livelihood (disobeyed Allah, and His Messengers, by doing evil deeds and crimes) ! And those are their dwellings, which have not been inhabited after them except a little. And verily! We have been the inheritors. And never will your Lord destroy the towns (populations) until He sends to their mother town a Messenger reciting to them Our Verses. And never would We destroy the towns unless the people thereof are Zalimun (polytheists, wrong-doers, disbelievers in the Oneness of Allah, oppressors and tyrants). [Soorah Qasas: Ayah:58-59]
He (The Most High) said:
وَضَرَبَ اللَّهُ مَثَلًا قَرْيَةً كَانَتْ آمِنَةً مُطْمَئِنَّةً يَأْتِيهَا رِزْقُهَا رَغَدًا مِنْ كُلِّ مَكَانٍ فَكَفَرَتْ بِأَنْعُمِ اللَّهِ فَأَذَاقَهَا اللَّهُ لِبَاسَ الْجُوعِ وَالْخَوْفِ بِمَا كَانُوا يَصْنَعُونَ
And Allah puts forward the example of a township (Makkah), that dwelt secure and well content; its provision coming to it in abundance from every place, but it (its people) denied the Favours of Allah (with ungratefulness). So Allah made it taste the extreme of hunger (famine) and fear, because of that (evil, i.e. denying Prophet Muhammad ) which they (its people) used to do.” [Soorah An-Nahl: Ayah:112]
He (The Most High) said:
لَقَدْ كَانَ لِسَبَإٍ فِي مَسْكَنِهِمْ آيَةٌ ۖ جَنَّتَانِ عَنْ يَمِينٍ وَشِمَالٍ ۖ كُلُوا مِنْ رِزْقِ رَبِّكُمْ وَاشْكُرُوا لَهُ ۚ بَلْدَةٌ طَيِّبَةٌ وَرَبٌّ غَفُورٌ
فَأَعْرَضُوا فَأَرْسَلْنَا عَلَيْهِمْ سَيْلَ الْعَرِمِ وَبَدَّلْنَاهُمْ بِجَنَّتَيْهِمْ جَنَّتَيْنِ ذَوَاتَيْ أُكُلٍ خَمْطٍ وَأَثْلٍ وَشَيْءٍ مِنْ سِدْرٍ قَلِيلٍ
ذَٰلِكَ جَزَيْنَاهُمْ بِمَا كَفَرُوا ۖ وَهَلْ نُجَازِي إِلَّا الْكَفُورَ
Indeed there was for Saba’ (Sheba) a sign in their dwelling place, – two gardens on the right hand and on the left (and it was said to them) “Eat of the provision of your Lord, and be grateful to Him, a fair land and an Oft-Forgiving Lord. But they turned away (from the obedience of Allah), so We sent against them Sail Al-‘Arim (flood released from the dam), and We converted their two gardens into gardens producing bitter bad fruit, and tamarisks, and some few lote-trees. Like this We requited them because they were ungrateful disbelievers. And never do We requit in such a way except those who are ungrateful, (disbelievers).” [Soorah Saba Aayaat: 15-17]
إِنَّ قَارُونَ كَانَ مِنْ قَوْمِ مُوسَىٰ فَبَغَىٰ عَلَيْهِمْ ۖ وَآتَيْنَاهُ مِنَ الْكُنُوزِ مَا إِنَّ مَفَاتِحَهُ لَتَنُوءُ بِالْعُصْبَةِ أُولِي الْقُوَّةِ إِذْ قَالَ لَهُ قَوْمُهُ لَا تَفْرَحْ إِنَّ اللَّهَ لَا يُحِبُّ الْفَرِحِينَ
Verily, Qarun (Korah) was of Musa’s (Moses) people, but he behaved arrogantly towards them. And We gave him of the treasures, that of which the keys would have been a burden to a body of strong men. When his people said to him: “Do not be glad (with ungratefulness to Allah’s Favours). Verily! Allah likes not those who are glad (with ungratefulness to Allah’s Favours).
َابْتَغِ فِيمَا آتَاكَ اللَّهُ الدَّارَ الْآخِرَةَ ۖ وَلَا تَنْسَ نَصِيبَكَ مِنَ الدُّنْيَا ۖ وَأَحْسِنْ كَمَا أَحْسَنَ اللَّهُ إِلَيْكَ ۖ وَلَا تَبْغِ الْفَسَادَ فِي الْأَرْضِ ۖ إِنَّ اللَّهَ لَا يُحِبُّ الْمُفْسِدِينَ
But seek, with that (wealth) which Allah has bestowed on you, the home of the Hereafter, and forget not your portion of legal enjoyment in this world, and do good as Allah has been good to you, and seek not mischief in the land. Verily, Allah likes not the Mufsidun (those who commit great crimes and sins, oppressors, tyrants, mischief-makers, corrupts).
قَالَ إِنَّمَا أُوتِيتُهُ عَلَىٰ عِلْمٍ عِنْدِي ۚ أَوَلَمْ يَعْلَمْ أَنَّ اللَّهَ قَدْ أَهْلَكَ مِنْ قَبْلِهِ مِنَ الْقُرُونِ مَنْ هُوَ أَشَدُّ مِنْهُ قُوَّةً وَأَكْثَرُ جَمْعًا ۚ وَلَا يُسْأَلُ عَنْ ذُنُوبِهِمُ الْمُجْرِمُونَ
He said: “This has been given to me only because of knowledge I possess.” Did he not know that Allah had destroyed before him generations, men who were stronger than him in might and greater in the amount (of riches) they had collected. But the Mujrimun (criminals, disbelievers, polytheists, sinners, etc.) will not be questioned of their sins (because Allah knows them well, so they will be punished without account).
فَخَرَجَ عَلَىٰ قَوْمِهِ فِي زِينَتِهِ ۖ قَالَ الَّذِينَ يُرِيدُونَ الْحَيَاةَ الدُّنْيَا يَا لَيْتَ لَنَا مِثْلَ مَا أُوتِيَ قَارُونُ إِنَّهُ لَذُو حَظٍّ عَظِيمٍ
So he went forth before his people in his pomp. Those who were desirous of the life of the world, said: “Ah, would that we had the like of what Qarun (Korah) has been given? Verily! He is the owner of a great fortune.
وَقَالَ الَّذِينَ أُوتُوا الْعِلْمَ وَيْلَكُمْ ثَوَابُ اللَّهِ خَيْرٌ لِمَنْ آمَنَ وَعَمِلَ صَالِحًا وَلَا يُلَقَّاهَا إِلَّا الصَّابِرُونَ
But those who had been given (religious) knowledge said: “Woe to you! The Reward of Allah (in the Hereafter) is better for those who believe and do righteous good deeds, and this none shall attain except those who are patient (in following the truth).”
فَخَسَفْنَا بِهِ وَبِدَارِهِ الْأَرْضَ فَمَا كَانَ لَهُ مِنْ فِئَةٍ يَنْصُرُونَهُ مِنْ دُونِ اللَّهِ وَمَا كَانَ مِنَ الْمُنْتَصِرِينَ
So We caused the earth to swallow him and his dwelling place. Then he had no group or party to help him against Allah, nor was he one of those who could save themselves.
َأَصْبَحَ الَّذِينَ تَمَنَّوْا مَكَانَهُ بِالْأَمْسِ يَقُولُونَ وَيْكَأَنَّ اللَّهَ يَبْسُطُ الرِّزْقَ لِمَنْ يَشَاءُ مِنْ عِبَادِهِ وَيَقْدِرُ ۖ لَوْلَا أَنْ مَنَّ اللَّهُ عَلَيْنَا لَخَسَفَ بِنَا ۖ وَيْكَأَنَّهُ لَا يُفْلِحُ الْكَافِرُونَ
And those who had desired (for a position like) his position the day before, began to say: “Know you not that it is Allah Who enlarges the provision or restricts it to whomsoever He pleases of His slaves. Had it not been that Allah was Gracious to us, He could have caused the earth to swallow us up (also)! Know you not that the disbelievers will never be successful. [Soorah Qasas: Aayaat: 76-82]
And He (The Most High) said:
فَكُلًّا أَخَذْنَا بِذَنْبِهِ ۖ فَمِنْهُمْ مَنْ أَرْسَلْنَا عَلَيْهِ حَاصِبًا وَمِنْهُمْ مَنْ أَخَذَتْهُ الصَّيْحَةُ وَمِنْهُمْ مَنْ خَسَفْنَا بِهِ الْأَرْضَ وَمِنْهُمْ مَنْ أَغْرَقْنَا ۚ وَمَا كَانَ اللَّهُ لِيَظْلِمَهُمْ وَلَٰكِنْ كَانُوا أَنْفُسَهُمْ يَظْلِمُونَ
So We punished each (of them) for his sins, of them were some on whom We sent Hasiban (a violent wind with shower of stones) [as the people of Lout (Lot)], and of them were some who were overtaken by As-Saihah [torment – awful cry, etc. (as Thamud or Shu’aib’s people)], and of them were some whom We caused the earth to swallow [as Qarun (Korah)], and of them were some whom We drowned [as the people of Nuh (Noah), or Fir’aun (Pharaoh) and his people]. It was not Allah Who wronged them, but they wronged themselves. [Soorah Al-Ankaboot: Ayah: 40]
[Source: An Excerpt from ‘Al-Makhraj Minal Fitan’. page:161]