Praise be to Allah.
The matter of supplication (du‘aa’) is a matter of worship that is broad in scope, and it is one of the best, greatest and most beloved to Allah, may He be exalted, to the extent that the Prophet (blessings and peace of Allah be upon him) described du‘aa’ (supplication) as ‘ibaadah (worship). It was narrated by Ahmad (18849) and at-Tirmidhi (3232) that an-Nu‘maan ibn Basheer (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Indeed, du‘aa’ (supplication) is what ‘ibaadah (worship) is.” Then he recited the verse (interpretation of the meaning): “And your Lord says, ‘Call upon Me; I will respond to you.’ Indeed, those who disdain My worship will enter Hell [rendered] contemptible” [Ghaafir 40:60]. At-Tirmidhi said: It is hasan saheeh. It was also classed as saheeh by al-Albaani in Saheeh wa Da‘eef Sunan at-Tirmidhi (2969). See also: Tafseer at-Tabari (3/485).
With regard to supplication in the case mentioned here, there are two scenarios:
The first scenario:
The du‘aa’ has to do with a matter that has been determined and the person knows the outcome, such as if he knows that he has failed [an exam], so he prays to Allah to let him pass, or he knows that So-and-so has died, so he prays to Allah to bring him back to life. In this case, the du‘aa’ is pointless, and in fact is regarded as overstepping the mark in du‘aa’, because it is a prayer for something that is impossible.
It was narrated from ‘Abdullah ibn Mughaffal (may Allah be pleased with him) that he said: I heard the Messenger of Allah (blessings and peace of Allah be upon him) say: “There will be among this ummah people who overstep the mark in purification and supplication.” Narrated by Ahmad (17254) and Abu Dawood (96). Classed as saheeh by al-Albaani in Saheeh Sunan Abi Dawood –al-Umm (86).
Shaykh al-Islam Ibn Taymiyah said: Overstepping the mark in supplication may sometimes take the form of asking for something for which it is not permissible to ask, such as help to do or obtain something that is haraam; and sometimes it may take the form of asking for something that Allah will not do, such as asking Him to let him live until the Day of Resurrection, or asking Him to relieve him of things that are inevitable for human beings, such as the need to eat and drink, or asking Him to show him something of His unseen, or to make him among those who are infallible and protected from sin, or to give him a child without having a wife, and other things, the asking of which are a kind of transgression that Allah does not like, and He does not like the one who asks for them.
End quote from Majmoo‘ al- Fataawa (15/22).
Ibn ‘Aabideen said: It is haraam to ask for things that are ordinarily impossible, when he is not a prophet or wali (close friend of Allah), such as asking to be free of the need to breathe air, so that he can be safe from suffocation, or asking to be free from sickness throughout his lifetime, so that he can benefit from his strength and faculties always, when the normal state of affairs indicates that this is impossible… All of that is haraam.
End quote from Radd al-Muhtaar (4/121).
The second scenario:
When he knows that something has happened, as mentioned in the question, but he does not know what was decreed and came to pass. In this case, there is nothing wrong with offering supplication, and it is prescribed for him to turn to Allah, may He be exalted, praying for whatever he wants, for he does not know the decree of Allah that has already come to pass, whether it is good or bad. It was narrated by Ahmad (22694) – and classed as hasan by al-Albaani in Saheeh at-Targheeb wa’t-Tarheeb (1634) – from Mu‘aadh (may Allah be pleased with him), that the Prophet (blessings and peace of Allah be upon him) said: “Du’aa’ is of benefit with regard to that which has come down and that which has not come down [of calamities], so, O slaves of Allah, I enjoin you to persist in offering du‘aa’.”
The general meaning of the Prophet’s words, “Du’aa’ is of benefit with regard to that which has come down and that which has not come down [of calamities]”, indicates that it is prescribed to offer supplication in the manner described.
Al-Mubarakfoori said in Tuhfat al-Ahwadhi (5/427), regarding the Prophet’s words, “Nothing can put back the divine decree except supplication”: … He enjoined us to seek medical treatment and offer supplication, even though what has been decreed will surely come to pass, because it [the divine decree] is hidden from people and they do not know what will happen and what will not happen. This is supported by the report narrated by at-Tirmidhi from Ibn ‘Umar: “Du’aa’ is of benefit with regard to that which has come down and that which has not come down [of calamities].” End quote.
So long as a person does not know what has been decreed, it is prescribed for him to offer supplication for the good things that he seeks, and to be spared the bad things that he fears and seeks to protect himself from. In that case, his du‘aa’ is included in the general meaning of the texts which encourage and urge us to offer supplication, such as the words of the Prophet (blessings and peace of Allah be upon him): “There is no Muslim who offers a supplication in which there is no sin or severing of ties of kinship, but Allah will give him one of three things in return for it: either He will hasten for him what he asked for, or He will store it [the reward for it] up for him in the Hereafter, or He will avert from him an equivalent evil.” They said: Then we should do a lot of that [offering supplication]. He said “Then Allah will reward you more.” Narrated by Ahmad in al-Musnad (11133) from Abu Hurayrah (may Allah be pleased with him); classed as saheeh by al-Albaani in Saheeh at-Targheeb wa’t-Tarheeb (1633).
And Allah knows best.