If the woman does not have any wali who can give her in marriage, then that role may be filled by the Muslim qaadi (judge), if there is one. If there is no qaadi, as is the case for Muslim communities living in the West, then the director of the Islamic centre may give her in marriage.
If there is no director of an Islamic centre, then the imam of the mosque, or a scholar, or a Muslim man of good character may give her in marriage.
If the woman is in a country where there is no wali – no brother, no father, and no paternal cousin – then the ruler takes the place of the wali; her wali is the ruler, because the Prophet (blessings and peace of Allah be upon him) said: “The ruler is the wali of the one who does not have a wali.” So the ruler takes the place of her wali and becomes her wali; he may give her in marriage or appoint someone else to give her in marriage. If she is in a land where there is no (Muslim) ruler, qaadi or wali, as in the case of Muslim minorities in non-Muslim countries, then the director of the Islamic Centre may give her in marriage, if there is an Islamic centre, because his position is like that of the ruler for them. The director of the Islamic Centre may look at her case and give her in marriage to one who is compatible, if she does not have any guardians of her own and there is no qaadi.
Shaykh al-Islam said: In the case of a woman who does not have a wali among her relatives, if there is in her locality a representative of the ruler or the chief of the village, or a leader who is obeyed, then he can do the marriage contract for her with her permission. (32/35).