Praying in congregation is obligatory for the one who can hear the call. If your house is so far away from the mosque that you cannot hear the adhaan if the muezzin raises his voice without the aid of a loudspeaker, when the wind and other noises etc. that could affect your hearing it are silent, then you are not obliged to attend congregational prayers in the mosque.
With regard to Jumu’ah prayer, the scholars are unanimously agreed that it is obligatory for every man who is in the city, whether he can hear the call or not, and no matter how far apart the city limits are.
For more information, see the answer to question no. 39054
So long as the imam is outwardly a Muslim, it is not permissible to abandon Jumu’ah and prayer in congregation behind him because of the possibility that he may be a Shi’ah or a Sufi, unless it is possible to establish another congregation for praying Jumu’ah and prayers in jamaa’ah – without causing any fitnah – behind another imam who is known to be righteous and following a sound way, in which case it is better to pray behind that one.
The basic principle is that we should think positively of Muslims, and not impugn their religious commitment or path without proof. The correct view is that it is valid to pray behind anyone whom we regard as a Muslim, so long as he does not do anything that constitutes kufr, such as believing that the Qur’aan has been altered or regarding the companions of the Prophet (peace and blessings of Allaah be upon him) as kaafirs, or praying to the dead and seeking their help. We should not pray behind one who does such things.
Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him) was asked about praying behind al-muraaziqah and about their bid’ah.
He replied: It is permissible for a man to offer the five daily prayers and Jumu’ah etc behind a person whom he does not know to engage in bid’ah or evildoing, according to the consensus of the four Imams and other imams of the Muslims. It is not one of the conditions of leading prayers that the person praying behind the imam should know what his imam’s beliefs are, and he should not examine him by saying, “What do you believe?” Rather he should pray behind the one whose situation he does not know. If he prays behind one who he knows to be an evildoer or innovator, then there are two well-known scholarly views concerning the validity of his prayer in the madhhab of Ahmad and Maalik; the view of al-Shaafa’i and Abu Haneefah is that his prayer is valid.
If the person knows that the imam is an innovator who calls others to follow his bid’ah, or an evildoer who commits evil openly, and he is the regular imam and it is not possible to pray behind anyone else, such as the imam for Jumu’ah and Eid prayers, or the imam in Hajj prayers at ‘Arafah and so on, then he should pray behind him, according to the majority of earlier and later scholars. This is the view of Ahmad, al-Shaafa’i, Abu Haneefah and others.
Hence they said concerning ‘aqeedah: He should offer Jumu’ah and Eid prayers behind any imam, whether he is righteous or an evildoer. Similarly, if there is only one imam in a village, then the prayers in congregation should be offered behind him, because praying in congregation is better than praying alone, even if the imam is an evildoer. This is the view of the majority of scholars, Ahmad ibn Hanbal, al-Shaafa’i and others. Prayer in congregation is obligatory for individuals according to the view of Ahmad. Whoever abandons Jumu’ah prayer and prayer in congregation behind an imam who is an evildoer is an innovator according to Imam Ahmad and other imams of al-Sunnah.
The correct view is that he should pray and not repeat the prayers. The Sahaabah used to offer Jumu’ah prayers and prayers in congregation behind imams who were evildoers, and they did not repeat the prayers. Ibn ‘Umar used to pray behind al-Hajjaaj, and Ibn Mas’ood and others prayed behind al-Waleed ibn ‘Uqbah, who used to drink wine. The prayer of an evildoer or innovator is valid in and of itself, so if a person prays behind him, his prayer is not invalid.
But with regard to those who disliked the idea of praying behind one who is an evildoer, they based their view on the fact that enjoining what is good and forbidding what is evil is obligatory. So one who openly commits bid’ah or evil should not be appointed as the regular imam for the Muslims. He deserves to be rebuked until he repents, and if it is possible to shun him until he repents, then that is good. If some of the people stop praying behind him and pray behind someone else, that may affect him and make him repent or withdraw or make the people stop committing sins like his. Stopping praying behind such a man may serve a purpose so long as people do not miss out on praying Jumu’ah or other prayers in congregation. But if stopping praying behind him means that people will miss out on praying Jumu’ah or other prayers in congregation, then in this case no one will stop praying behind him but one who is an innovator and who goes against the Sahaabah (may Allaah be pleased with them).
End quote from Majmoo’ al-Fataawa, 23/351- 356
The scholars of the Standing Committee were asked: What is the ruling on eating meat when nothing is known about the slaughterer’s ‘aqeedah, or praying behind one whose ‘aqeedah is unknown? They replied: If he is outwardly Muslim, but his ‘aqeedah is unknown, and it is not known whether his ‘aqeedah is deviant, then it is valid to pray behind him and meat slaughtered by him may be eaten. End quote.
Fataawa al-Lajnah al-Daa’imah, 7/365
It also says (7/353): With regard to praying behind an innovator, if their bid’ah involves shirk such as calling upon anyone other than Allaah, making vows to anyone other than Allaah, or believing that their shaykhs possess qualities that belong only to Allaah, such as complete knowledge or knowledge of the unseen or the ability to influence events, then it is not valid to pray behind them.
But if their bid’ah does not involve shirk, such as reciting dhikrs that have been narrated from the Prophet (peace and blessings of Allaah be upon him) but in unison and swaying, then it is valid to pray behind them, but the Muslim should try to find an imam who does not follow innovation, because that will bring a greater reward and be further removed from evil. End quote.
Shaykh Ibn Baaz (may Allaah have mercy on him) was asked: What is the ruling on one who lives in a city whose people adhere to bid’ah? Is it valid for him to offer Jumu’ah and prayers in congregation with him, or should he pray on his own, or is the obligation of Jumu’ah waived for him? If there are less than twelve of ahl al-sunnah in a city, is Jumu’ah valid for them or not?
He replied: It is obligatory to establish Jumu’ah prayer behind any imam, righteous or otherwise. If the bid’ah of the imam for Jumu’ah does not put him beyond the pale of Islam, then he should pray behind him. Imam Abu Ja’far al-Tahhaawi (may Allaah have mercy on him) said in his famous book al-‘Aqeedah: We think that prayer should be offered behind any imam, righteous or otherwise, among the people of the qiblah, and (the funeral prayer) should be offered for those of them who die. End quote. Then he quoted the words of the former Shaykh of Islam: … as for the second question, the answer is: There is a well-known dispute among the scholars concerning this issue, but the correct view is that it is permissible to establish Jumu’ah prayer with three or more, if they are residents of a village in which Jumu’ah prayers are not held. As for the stipulation that there be forty or twelve or less or more in order to hold Jumu’ah prayers, there is no reliable evidence for that as far as we know. Rather what must be done is to establish prayers in congregation and the smallest number for that is three. This is the view of a number of scholars, and is the view favoured by Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him), and this is the correct view, as stated above.
End quote from Majmoo’ Fataawa al-Shaykh Ibn Baaz, 4/303
You should cooperate with the community that is in that land, and call them to Allaah, and correct their ‘aqeedah, teaching those who have gone astray, with wisdom and beautiful preaching, so that the prayers will be led by the best and most pious of them.
We ask Allaah to help and guide us and you.
And Allaah knows best.