The Command to call on Allah when Calamity strikes, to repel Evil with that which is better, and to seek refuge with Allah
Allah commands His Prophet Muhammad ﷺ to call on Him with this supplication when calamity strikes:
رَّبِّ إِمَّا تُرِيَنِّى مَا يُوعَدُونَ
(My Lord! If You would show me that with which they are threatened.) meaning, `if You punish them while I am witnessing that, then do not cause me to be one of them.' As was said in the Hadith recorded by Imam Ahmad and At-Tirmidhi, who graded it Sahih:
Allah instructs the Holy Prophet ﷺ to counter evil with good, oppression with justice and cruelty with mercy. These virtues of conduct have been taught by Allah to the Holy Prophet ﷺ and are generally observed in settling affairs among the Muslims. Later on these instructions were repealed in so far as the infidels and the unbelievers were concerned when Allah permitted Muslims to embark on (Jihad). Nevertheless even during Jihad the Muslims were told to adopt a humane approach towards the enemy. For example they were forbidden to kill women and children or the priests who did not engage in battle against the Muslims. Similarly, mutilation of the dead bodies of enemies was strictly forbidden. It is for this reason that the Holy Prophet ﷺ is instructed in the next verse to seek protection from Shaitan's evil suggestions even in the battle fields where he may arouse emotions to act against ethics.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 95–97
This prayer illustrates that a believer is always a God-fearing man. Even when God’s punishment is directed towards others, he starts trembling with fear. He starts addressing God in all humility, because he knows that, if he is to be saved, it will not be by any deed of his or by his own strength but by God’s mercy.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.