Dr. Ali Gomaa, former Grand Mufti and senior scholar, explained that if a person prays Dhuhr and completes only three rak‘ahs by mistake, and remembers during the final sitting, they may perform the fourth rak‘ah immediately. If a rak‘ah is forgotten, it can be made up if remembered shortly after, such as during the concluding sitting or with brief conversation, as stated in the Hadith of Dhu’l-Yadain. However, if remembered after leaving the prayer and attending to worldly matters, the prayer must be repeated in full.
Regarding Qibla direction, Gomaa emphasized that facing the Kaaba is a condition for valid prayer, citing the Qur’anic verse: {So wherever you turn, there is the Face of Allah}. If someone prays towards the wrong direction despite efforts to ascertain it and realizes the error during the prayer, it must be resumed. If realized after finishing, it must be repeated according to the preferred opinion of the Shafi‘i school. Those unaware of the error are excused but should correct the direction once known.



