Interrupting the prayer because of an earthquake and the like
Question

Is it permissible to interrupt the prayer during an earthquake and similar natural disasters?
Praise be to Allah.Firstly:
If the prayer is voluntary, then the matter is flexible, because interrupting a voluntary prayer with no excuse is permissible, so when there is an excuse it is more appropriate that it should be permissible.
This is the view of the Shafa‘is and Hanbalis, and it is the correct view. The evidence for that is as follows:
The hadith of ‘A’ishah, the Mother of the Believers, who said: The Prophet (blessings and peace of Allah be upon him) came in one day and said: “Do you have anything (to eat)?”
We said: No.
He said: “Then I am fasting.”
Then he came to us on another day and we said: O Messenger of Allah, we have been given some hays (a dish made of dates with ghee and dried yoghurt). He said: “Show it to me, for I woke up this morning fasting,” then he ate.
Narrated by Muslim (1154).
It says in al-Mawsu‘ah al-Fiqhiyyah al-Kuwaitiyyah (34/51):
With regard to interrupting a voluntary act of worship after starting it, the jurists differed concerning the ruling thereon. The Hanafis and Malikis said it is not permissible to interrupt it after starting it without an excuse, as in the case of an obligatory act of worship, and it must be completed, because it is an act of worship.
The Shafa‘is and Hanbalis said: It is permissible to interrupt a voluntary act of worship, except Hajj and ‘umrah, because of the hadith, “The one who is doing a supererogatory act of worship is in charge of himself.” The version narrated by at-Tirmidhi from Umm Hani’ says: “The fasting person is in charge of himself.” But it is better (mustahabb) to complete it.
In the case of Hajj and ‘umrah, they must be completed, even if they are spoiled, if one has already started them, because in this case, what is supererogatory is like what is obligatory. End quote.
Secondly:
If, however, the prayer is obligatory, then the basic principle is that the one who has started an obligatory prayer is not permitted to interrupt it except for a legitimate excuse.
It says in al-Mawsu‘ah al-Fiqhiyyah al-Kuwaitiyyah (34/51):
Interrupting an obligatory act of worship after having started it without any Islamically acceptable justification is not permissible, according to the consensus of the jurists, because interrupting it without any Islamically acceptable justification is foolishness which is contrary to the sanctity of worship, and it is prohibited to spoil acts of worship. Allah, may He be exalted, says (interpretation of the meaning):
{and do not invalidate your deeds} [Muhammad 47:33].
As for interrupting the prayer with an Islamically acceptable justification, that is prescribed. So the worshipper may interrupt his prayer in order to kill a snake and the like, because we have been instructed to kill them; or for fear of losing some valuable property, whether it belongs to him or to someone else; or to help someone in desperate need who is calling for help; or to alert someone who is heedless or is asleep, towards whom a snake or the like is heading, and he cannot be alerted by saying tasbih. And one who is fasting may break his fast in order to save someone who is drowning, or when he fears for himself or for an infant. End quote.
Undoubtedly the occurrence of earthquakes, floods and the like come under the headings of excuses which make it permissible to interrupt the obligatory prayer. In fact, it must be interrupted in such cases, if by interrupting it the worshipper will be able to save himself or one of his brothers. Allah, may He be exalted, says (interpretation of the meaning):
{and do not throw [yourselves] with your [own] hands into destruction} [al-Baqarah 2:195].
There were several views regarding the meaning of this verse among the early generations.
In fact, what matters is the general meaning of the words, not the specific reason for revelation. So anything that may be correctly described as destruction in either religious or worldly affairs is included in this verse. This is the view of Ibn Jarir at-Tabari."(Fath al-Qadir  1/222).
The scholars have mentioned a number of reasons which make it permissible to interrupt the prayer. The Hanbalis differentiated between danger which threatens the worshipper and danger which threatens others.
In the case of danger which threatens others, he should interrupt his prayer to deal with it, then repeat the prayer after that.
As for danger which threatens him, he should not interrupt his prayer to deal with it; rather he should move away, flee and save himself from it, even if that means turning his back to the qiblah, moving a great deal and running, whilst still praying, acting in accordance with the verse which speaks about the fear prayer, because it does not refer only to fear of enemies.
Allah, may He be exalted, says (interpretation of the meaning):
{And if you fear [an enemy, then pray] on foot or riding} [al-Baqarah 2:239].
Shaykh Ibn ‘Uthaymin said in Tafsir Surat al-Baqarah (239): {And if you fear} means: you fear that something bad may happen if you continue what you are doing, so that if you been scared by an enemy, or a fire, or a flood, or other things that people fear, then pray {on foot or riding}. End quote.
{And if you fear} – the verse does not mention what is feared, so that it may include a disbeliever, a wrongdoer, a wild animal, or other frightening things.
{on foot or riding} what this implies is that they may be facing towards the qiblah or they may not."(Ibn Qudamah said in al-Mughni  3/97):
If the worshipper needs to move a great deal whilst praying for an unnecessary reason, he should interrupt his prayer and do whatever he needs to do.
Ahmad said: If he sees two boys fighting, and fears that one of them may throw the other into the well, then he should go and pull them apart, then return to his prayer.
And he said: If one man is keeping hold of another [because he owes him a debt or the like], and they enter the mosque and the iqamah for prayer is given, then when the imam prostrates, the one who was being held runs away, then the one who was holding on to him may run after him.
Then after that, he must start his prayer all over again.
The same applies if he sees a fire that he wants to extinguish, or he sees someone drowning and wants to save him. He should go out and deal with the matter, then start his prayer all over again.
If the fire or flood reaches him whilst he is praying, so he flees from it, he may resume his prayer [from the point he had reached before he fled] and complete it, like the fear prayer. And Allah knows best."(Al-Mirdawi said in al-Insaf  3/658):
It is obligatory to protect a disbeliever who is living under the protection of the Muslims from falling into a well, if one is praying, according to the more correct of the two views, just as it is obligatory to protect a Muslim from that. So the worshipper should interrupt his prayer [to do that], then start his prayer all over again, according to the correct view. It was also said that he may resume his prayer and complete it.
Similarly, it is permissible to interrupt the prayer if the man who he is holding because he owes him a debt runs away from him. Hubaysh narrated from Imam Ahmad that he should chase him. He may also interrupt his prayer to save one who is drowning and the like, according to the correct view. End quote.
More than one of the early generations and leading scholars were of the view that this concession allowing one to interrupt the prayer applies in frightening situations and times of escalating danger.
Ibn Rajab al-Hanbali (may Allah have mercy on him) said:
Qatadah said: If someone snatches his garment, he may chase the thief and leave the prayer.
‘Abd ar-Razzaq narrated in his book, from Ma‘mar, from al-Hasan and Qatadah:
Regarding a man who is praying, but he is worried that his mount may run away or a wild animal may attack it.
They said: He should stop praying [and go and deal with the matter].
It was narrated from Ma‘mar that Qatadah said: I asked him: What if a man is praying and he sees a child at the edge of a well, and is afraid that he may fall into it. Can he stop praying [and go and deal with the matter]?
He said: Yes.
I said: What if he sees a thief who wants to take his shoes?
He said: He should stop praying [and go and deal with the matter].
The view of Sufyan is that if there is escalating danger and a man is praying, he should stop praying [and go and deal with the matter].
This was narrated from him by al-Mu‘afa.
Similarly, [he should stop praying and go and deal with the matter] if he fears that a flood will take his flocks or his mount.
The view of Malik is that if someone’s mount starts to walk away whilst he is praying, he may walk towards it and stay close to it if it is in front of him or to his right or left, and if it goes far away he may chase it and interrupt his prayer.
The view of our companions is that if he sees someone drowning, or he sees a fire or two boys fighting, and the like, and he is able to deal with the matter, then he should interrupt his prayer and deal with it.
Some scholars restricted [this concession] to supererogatory prayer, but the more correct view is that it includes both obligatory prayers and others.
Ahmad said, regarding one who is holding on to a man [who owes him a debt and the like] and they both go to pray, then that man runs away whilst he is praying: He should go out after him.
Ahmad also said: If he sees a child about to fall into a well, he should interrupt his prayer and save him.
One of our companions said: He should only interrupt his prayer if he needs to move a great deal in order to save him, because if the movement is slight, it does not invalidate the prayer.
This was the view of Abu Bakr regarding one who goes out and sees that the one who owes him a debt or the like is coming back: he may come back and resume his prayer.
Al-Qadi interpreted it as referring to slight movements.
It may also be said that if he fears for his property, then his movements may be overlooked, even if he moves a great deal."(Fath al-Bari by Ibn Rajab  9/337-338).
Conclusion
There is nothing wrong with one who is praying interrupting his prayer if an earthquake, fire or other disaster or calamity occurs, if he fears that something may happen as a result of that to himself or his property, or he fears for the life or property of someone who is protected according to sharia.
And Allah knows best.