In 622 CE, Prophet Muhammad and his followers migrated from Mecca to Yathrib (later renamed Medina) to escape persecution by the Quraysh tribe. Muhammad, accompanied by Abu Bakr, completed the journey in September 622 to a community that had invited him as mediator and leader. He established the first mosque and negotiated the Constitution of Medina, a formal agreement among Muslim, Jewish, and Arab tribes that created the first Islamic polity. Caliph Umar later designated 622 CE as Year 1 AH, establishing the epoch for the Islamic Hijri calendar.