Praise be to Allah.
Ruqyah as prescribed in Islamic teaching is mustahabb. The Prophet (blessings and peace of Allah be upon him) did ruqyah for himself, and his companions (may Allah be pleased with them) did ruqyah for themselves. It is one of the Islamically-prescribed remedies that a person may use to protect himself from physical and psychological harm, and harm caused by the devils.
There is no specific time for doing ruqyah; rather it may be done at any time of the night or day, but if a person tries to do it at times when supplications are answered – such as the last part of the night – then that is good, in sha Allah, but it is not because ruqyah is connected to a specific time; rather it is because ruqyah is in fact a du‘aa’ (supplication) and turning to Allah, so if one seeks out a time when supplications are answered, that is good. The same applies to all times in which it is hoped that supplications will be answered.
However it is prescribed at all times, and the reports in the Sunnah which mention it did not limit it to one time and not another.
Al-Bukhaari (4439) and Muslim (2192) narrated from ‘Aa’ishah (may Allah be pleased with her) that when the Messenger of Allah (blessings and peace of Allah be upon him) fell ill, he would blow on himself and recite the Mu‘awwidhaat, and wipe his hand over him. She said: When he became ill with what would be his final illness, I began to blow on him and recite the Mu‘awwidhaat that he used to recite and blow on himself, and wipe over the Messenger of Allah (blessings and peace of Allah be upon him) with his own hand.
Ibn ‘Abd al-Barr (may Allah have mercy on him) said:
This indicates that ruqyah is something proven by the texts, and it is a refutation of those Muslims who reject it; it also indicates that ruqyah may be done by reciting Qur’an.
End quote from at-Tamheed (8/129).
Muslim (2185) narrated from ‘Aa’ishah that she said: When the Messenger of Allah (S) fell sick, Jibreel (peace be upon him) would recite ruqyah for him, saying: “Bismillahi yubreek, wa min kulli daa’in yashfeek, wa min sharri haasidin idha hasad, wa sharri kulli dhi ‘ayn (In the name of Allah, may He cure you, from every disease may He heal you, from the evil of the envier when he envies and from the evil of every evil eye).”
And Muslim (2186) narrated from Abu Sa‘eed that Jibreel came to the Prophet (blessings and peace of Allah be upon him) and said: O Muhammad, are you ill” He said, “Yes.” He said, “Bismillaahi arqeeka min kulli shay’in yu’dheeka, min sharri kulli nafsin aw ‘aynin haasid Allaahu yashfeek, bismillaahi arqeek (In the name of Allah I perform ruqyah for you, from everything that is harming you, from the evil of every soul or envious eye may Allah heal you, in the name of Allah I perform ruqyah for you).”
Al-Bukhaari (5742) narrated that ‘Abd al-‘Azeez ibn Suhayb said: Thaabit and I went to Anas ibn Maalik and Thaabit said: O Abu Hamzah, I am sick. Anas said: Shall I not do ruqyah for you with the ruqyah of the Messenger of Allah (blessings and peace of Allah be upon him)? He said: Yes. He said: Allaahumma Rabb an-naas, mudhhib al-ba’s, ishfi anta ash-Shaafi, laa shaafiya illa anta, shifaa’an laa yughaadir saqaman (O Allah, Lord of mankind, the One Who relieves hardship, grant healing, for there is no healer but You, a healing that leaves no trace of sickness) .
It is mustahabb to do ruqyah before sleeping, because of the report narrated by al-Bukhaari (5017) from ‘Aa’ishah, that when the Prophet (blessings and peace of Allah be upon him) went to his bed every night, he would hold his hands together, then he would spit dryly into them and recite into them “Qul huwa Allahu ahad”, “Qul a‘oodhu bi Rabb il-Falaq” and “Qul a‘oodhu bi Rabb il-Naas” [i.e., the last three soorahs of the Qur’an], then he would wipe whatever he could of his body with his hands, starting with his head and face, and the front of his body. He would do that three times.
Islamic teaching does not specify a particular length of time for ruqyah remaining effective. What is prescribed, if a person falls sick, is for him to do ruqyah for himself, and to continue to do so until he recovers, by Allah’s leave, just as he would continue to take medicine until he recovers, by Allah’s leave.
What is said about ruqyah remaining effective for ten days, and the like, is a view for which there is no evidence. Rather what is prescribed for the Muslim, if he falls sick, is to recite ruqya over himself until he recovers.
See also the answer to question no. 3476.
And Allah knows best.