Bay’ah can only be given to the leader of the Muslims, and bay’ah is given by the decision makers – i.e., the scholars and people of virtue and status. Once they give their allegiance to him, his position of leadership is confirmed, and the common folk do not have to give allegiance to him themselves, rather they have to obey him so long as that does not entail disobedience towards Allaah.
Al-Maaziri said: With regard to bay’ah being given to the leader of the Muslims, it is sufficient for the decision makers to give him their bay’ah. It is not essential for each individual Muslim to come to him and put his hand in his, rather it is sufficient to commit oneself to obeying him and submitting to him by not going against him or rebel against him.
Quoted from Fath al-Baari.
Al-Nawawi (may Allaah have mercy on him) said in Sharh Saheeh Muslim:
With regard to bay’ah (oath of allegiance): the scholars are agreed that in order for it to be valid it is not essential for all the people or all the decision makers to give their bay’ah. Rather, if bay’ah is given by those scholars and people of virtue and status who are present, that is sufficient. It is not obligatory for each person to come to the leader and put his hand in his and give his oath of allegiance to him. Rather what is required of each individual is to submit to him and not go against him or rebel against him.
What is narrated in the ahaadeeth narrated in the books of Sunnah about bay’ah refers to giving allegiance to the Muslim leader, such as when the Prophet (peace and blessings of Allaah be upon him) said: “Whoever dies and did not make an oath of allegiance (to the Muslim leader) has died a death of jaahiliyyah.” (Narrated by Muslim, 1851).
And he (peace and blessings of Allaah be upon him) said: “Whoever gives his oath of allegiance to a leader and gives him his hand and his heart, let him obey him as much as he can. If another one comes and disputes with him (for leadership), kill the second one.” (Narrated by Muslim, 1844)
And he (peace and blessings of Allaah be upon him) said: “If allegiance is given to two khaleefahs, then kill the second of them.” (Narrated by Muslim, 1853).
All of that undoubtedly has to do with giving allegiance to the Muslim leader.
Shaykh Saalih al-Fawzaan (may Allaah preserve him) said, answering a question about giving allegiance to the various groups: Bay’ah only has to do with the leader of the Muslims; these various bay’ahs are innovated and they are among the causes of division. The Muslims who are living in one country or one kingdom should have one allegiance to one leader; it is not permissible to have several kinds of bay’ah. al-Muntaqa min Fataawa al-Shaykh Saalih al-Fawzaan, 1/367
With regard to how the allegiance should be given to the leader, in the case of men it is done in word and in deed, namely with a handshake. In the case of women, it is done by word only. This is proven in the ahaadeeth which speak of how allegiance was given to the Messenger of Allaah (peace and blessings of Allaah be upon him).
For example, ‘Aa’ishah (may Allaah be pleased with her) said: “No, by Allaah, the hand of the Messenger of Allaah (peace and blessings of Allaah be upon him) never touched the hand of any (non-mahram) woman. Rather he would accept their allegiance (bay’ah) in words only.”
(Narrated by al-Bukhaari, 5288; Muslim, 1866)
Al-Nawawi (may Allaah have mercy on him) said in his Sharh (commentary): “This indicates that for women, allegiance is given in words only, without taking the hand of the leader, and for men it is done in words and by taking his hand.
And Allaah knows best.