September 20[2] or June 28[3] – Muhammad does not enter Yathrib directly, but stops at its outlying environs of Quba. He establishes the Quba Mosque here, the first mosque of Islam. On July 2 (or September 24) he makes his first visit to Yathrib for Friday prayers.
October 4[2] or July 13 – After a fourteen days' stay in Quba, Muhammad finally moves from Quba to Yathrib, and is greeted cordially by its people. Here he drafts the Constitution of Medina, an agreement between the various Muslim, Jewish, Christian and pagan tribal communities in the city, forming the basis of a multi-religious Islamic state, and begins construction of the Al-Masjid an-Nabawi Mosque. Later during the caliphate of Umar in 638, the lunar year during which the emigration to Medina occurred (Friday 16 July 622 – 4 July 623) is designated "Year One" of the new Hijri era (Anno Hegirae – AH).