If I am unable to find the direction towards Makkah sharif, the qibla, is it okay to offer salat/namaz towards a direction other than qibla?
Let's start answering for the case of an average person who has no special health conditions hindering him/her to seek the qiblah:
The only possible situation which may give a permission is that of a person whom for whatever reason can't even see the sun, as by observing the movement of the sun you might have the chance to conclude a > 90° deviation from the qiblah. This might apply for prisoners or people who have got stuck in a cave or in a mine etc.. For these people the verse:
And to Allah belongs the east and the west. So wherever you [might] turn, there is the Face of Allah . Indeed, Allah is all-Encompassing and Knowing. (2:115)
Such people have both the necessity to pray and the permission to pray in whatever direction they think is correct!
An other possibility is a person who doesn't have an idea about the correct qiblah direction in his location, such a person must ask about it and try to find a good estimation of the qiblah direction, as Allah ordered as:
IMO such people should try to seek advice help if it is not available before the actual prayer time ended, they should at least pray their actual prayers and seek help later. Their situation could be considered similar to that of people who don't find water and are allowed to perform tayyamum instead of wudu'. But I have big doubts that this would have a wide acceptance for resident people as the internet can offer help and it would be generally easy to ask people for help etc. and I guess this is addressed in the last fatwa I linked in my post.
A similar situation is that of people traveling and having no idea about the actual qiblah location, these people are allowed to pray to the direction they believe is correct, after a certain search and effort for determining the direction and their prayer is valid this can be based on a hadith compiled by ad-Darqotni, al-Hakim and al-Bayhaqi
This is indicated by the hadeeth of Jaabir (may Allah be pleased with him) who said:
We were with the Messenger of Allah (blessings and peace of Allah be upon him) on a march or a campaign, and it became cloudy. We tried to determine the qiblah and differed concerning it, so each man prayed on his own, and one of us marked the direction he faced him so that he could check it later. The following morning we looked and found that we had prayed facing a direction other than the qiblah. We told the Prophet (blessings and peace of Allah be upon him) and he did not instruct us to repeat it, and he said: “Your prayer is valid.” (source: islamqa #148900)
Else you would hardly be allowed to deviate from the qiblah in a way that might be considered as ignoring the correct direction:
There is no difference of opinion among the scholars concerning the fact that facing the qiblah is one of the conditions of prayer being valid, and that failing to meet this condition – when one is able to do so – renders the prayer invalid. (same fatwa as above)
As Allah said():
... So turn your face toward al-Masjid al-Haram. And wherever you [believers] are, turn your faces toward it [in prayer]. Indeed, those who have been given the Scripture well know that it is the truth from their Lord. And Allah is not unaware of what they do. (2:144)
- The above situation so far apply for people who basically are able to face the qiblah and have no special necessity to avoid it such as a sick or old person who is unable to move by themselves and are not actually facing the qiblah or people in big fear like a person who is running away or fleeing from an enemies, or wild animals or drifted in a an ocean or river etc.. It is also permissible to pray while travelleing for example by car or airplane nafl -optional- prayers (especially, for fard -obligatory- prayers there's no consensus or one may redo the prayer later) to whatever direction it may face. See also islamqa #65853 for details and evidences.
See also these relevant posts: