The tradition of bayʿah can be traced back to the era of Muhammad. From the beginning bayʿah was taken by Muhammad as an oath of allegiance. Anybody who wanted to join the Islamic community did so by reciting the basic statement of the faith expressing his faith in the oneness of God and the prophethood of Muhammad. However, this differed from the proclamation of faith necessary to simply become a Muslim. In addition to this the prophet formally took bayʿah from the people and tribes. Through this formal act they entered the Islamic community and showed their willingness to follow and obey Muhammad. The wordings of the oath differ in different traditions but it contains the shahada and prayers of repentance.
It is reported that at the occasion of annual gatherings outside Mecca, Muhammad met people from Yathrib, later to be renamed Medina, who accepted his call towards Islam. Muhammad then took bayʿah from them.
Certainly Allah was well pleased with the believers when they swore allegiance to you under the tree, and He knew what was in their hearts, so He sent down tranquillity on them and rewarded them with a near victory,
The bay'ah of Rizwan, a collective initiation of thousands of Muslims at the hand of Muhammad, is mentioned in the Qur'an. The tradition was continued by the caliphs.