At the annual pilgrimage of the Ka'bah, people came to Mecca from all parts of Arabia. Taking advantage of the occasion Prophet (Peace Be Upon Him) met with half a dozen inhabitants of Madina who being neighbor of the Jews and the Christians, had some notion of prophets and Divine messages. They knew also that these "people of the Books" were awaiting the arrival of a Prophet - "a last comforter".
So these inhabitants of Madina (known as "Ansaar") decided not to lose the opportunity of obtaining an advance over others, and forthwith embraced Islam, promising further to provide additional adherents and necessary help from Madina. The following year a dozen more people from Madina took the oath of allegiance to him and requested him to provide with a missionary teacher. The Prophet (Peace Be Upon Him) appointed Mus'ab for the mission. The work of the missionary, Mus'ab, proved very successful and he led a contingent of seventy-three new converts to Mecca, at the time of the pilgrimage next year.
The teachings of Islam were so contagious that the people of the "Aus" and the "Khazraj" the two influential tribes of Yathrib (Madina), awakened to interest, quickly attested their faith in it. They took precedence over all other tribes of Arabia in welcoming and defending the religion of God.
These people invited the Prophet (Peace Be Upon Him) and his Meccan companions to migrate to their town, and promised to shelter the Prophet (Peace Be Upon Him) and to treat him and his companions as their own kith and kin.
The Prophet (Peace Be Upon Him) commanded the Muslims
in Mecca to migrate and join their brothers-in-faith, the Ansaar, in Madina.
He told his companions, "God has provided to you
some brethren and homes where you will live in safety." Therefore
the greater part of the Muslims emigrated to Madina in small groups , leaving
the Prophet (Peace Be Upon Him) behind in Mecca in
anticipation of the command of Allah as to when he should leave the city.