Why did Muhammad move from Mecca to the city Medina?

Muhammad moved from Mecca to Medina in 622 CE in an event known as the Hijrah. He and his followers were facing persecution and hostility in Mecca from the Quraysh tribe, who opposed Muhammad's teachings and the spread of Islam. The people of Medina, known as the Ansar, had invited him to come and act as a mediator and leader in their city.

The migration to Medina allowed Muhammad to establish a community of believers and practice Islam openly without fear of persecution. It also marked the beginning of the Islamic calendar and the growth of the Muslim community as a whole.