Earthquakes are signs from Allah, the Most High. A Muslim has to reflect on Allah’s creation and always be mindful of His signs. By earthquakes, Allah, the Almighty, may warn His servants against committing sins and violating His laws. Therefore, it’s our duty to repent to Allah, to seek His forgiveness, to do goodness and to keep away from prohibitions.
In this regard, we would like to cite for you the following fatwa issued by the late Saudi Muslim scholar Sheikh ibn Baz, in which he states the following: Allah is the All-Wise, All-Knowing in all that He wills and decrees, and He is also the All-Wise, All-Knowing in all that He legislates and commands. He creates and decrees any signs He wills in order to frighten His servants and remind them of their obligations and duties towards Him, as well as to warn them against associating anything in worship with Him, going against His commands and doing that which He has forbidden. Allah says: (And We sent not the signs except to warn.) (Al-Isra’ 17:59) (We will show them Our Signs in the universe, and in their own selves, until it becomes manifest to them that this (the Qur’an) is the truth. Is it not sufficient in regard to your Lord that He is a Witness over all things?) (Fussilat 41:53) (Say: He has power to send torment on you from above or from under your feet, or to cover you with confusion in party strife, and make you to taste the violence of one another.)(Al-An`am 6:65)

Al-Bukhari narrated in his Sahih from Jabir ibn `Abd-Allah (may Allah be pleased with him) that when the ayah (verse) (Say: He has power to send torment on you from above…) was revealed, the Prophet (peace and blessings of Allah be upon him) said, “A`udhu bi wajhika (I seek refuge in Your Face)…
abul-Shaykh Al-Isbahani narrated from Mujahid concerning the exegesis of this ayah, (Say: He has power to send torment on you from above.): (this means) the shout (extremely loud noise) or tumult, stones and strong wind; (or from under your feet), (means) earthquakes and being swallowed up by the earth.
Undoubtedly, the earthquakes that are happening these days are among the signs, which Allah uses to frighten His servants. All the earthquakes and other events which take place and cause harm and injury to people are because of shirk (associating other gods with Allah) and sins, as Allah says: (And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much.) (Ash-Shura 42: 30) and, (Whatever of good reaches you, is from Allah, but whatever of evil befalls you, is from yourself.) (An-Nisaa’ 4:79)
Allah, the Most High, says concerning the past nations: (So We punished each (of them) for his sins, of them were some on whom We sent Hasib (a violent wind with showers of stones), and of them were some who were overtaken by As-Saihah (torment — extremely loud noise ), and of them were some whom We caused the earth to swallow, and of them were some whom We drowned. It was not Allah, Who wronged them, but they wronged themselves.) (Al-`Ankabut 29: 40)
What Muslims must do is to repent to Allah, adhere firmly to His Religion and avoid all that He has forbidden of shirk and sin, so that they may be safe and attain salvation from all the evils of this world and the next, and so that Allah will ward off from them all harm, and bless them with all that is good. Allah says: (And if the people of the towns had believed and had piety, certainly, We should have opened for them blessings from the heavens and the earth, but they belied (the Messengers). So We took them (with punishment) for what they used to earn (polytheism and crimes).) (Al-A`raf 7:96)
Ibn Al-Qayyim (may Allah have mercy on him) said: “Allah sometimes gives the earth permission to breathe, which is when major earthquakes occur, and this makes people feel afraid, so they repent, give up sins, pray to Allah and feel regret [for their sins]. Whenever there was an earthquake, some of the salaf (early Muslims) would say: Your Lord is warning you. Also, when Madinah was struck by an earthquake, `Umar ibn Al-Khattab (may Allah be pleased with you) addressed the people, saying: If there is another earthquake, I will not stay here with you.”
Our reaction, when there is an earthquake or some other sign such as an eclipse, strong winds or floods, should be to hasten to repent to Allah and pray to Him for safety, and to remember Him much and seek His forgiveness, just as the Prophet (peace and blessings of A
llah be upon him) said when there was an eclipse: “If you see anything like that, hasten to remember Him, call on Him and seek His forgiveness…” (Al-Bukhari and Muslim)
It is also recommended to show compassion to the poor and needy, and to give them charity, because the Prophet (peace and blessings of Allah be upon him) said: “Show mercy, and you will be shown mercy.” (Imam Ahmad) “Whoever does not show mercy will not be shown mercy.” (Al-Bukhari and Muslim)
It was reported that when there was an earthquake, `Umar ibn ‘Abd al-‘Azeez (may Allah have mercy on him) would write to his governors telling them to give in charity.
the Prophet (peace and blessings of Allah be upon him) said: “Whoever meets the needs of his brother, Allah will meet his needs.” (Al-Bukhari and Muslim)