In 622, Muhammad (PBUH) migrated to Madina by the order of Allah and the Muslims hailed Allah o Akbar on His arrival in joy.
During His stay in Qubaa, he established the first ever mosque, Qubaa in Muslim era. On Friday, Prophet (PBUH) led the Muslims on the Friday prayer, and gave his first sermon. Upon his arrival to Madina, Muslim families invited the Messenger of Allah (PBUH) to stay with them.
In order not to turn down the request of any one of them, the Muhammad (PBUH) decided that He would stay where His she-camel would stop by. Camel kept on walking until she reached the door of the house of Abu Ayyub, who happened to be amongst the poorest in Madina. Then Abu Ayyub hurried to the Prophet’s baggage and took it into his house.