When persecution grew severe, Allah permitted the migration to Madinah. The Prophet ﷺ left with Abu Bakr, hiding three nights in the cave of Thawr while Quraysh searched for them.
When the searchers stood at the cave mouth, Abu Bakr feared for the Prophet ﷺ, who calmed him with the words recorded in the Quran: "Do not grieve; indeed Allah is with us" (9:40).
The Hijrah was so momentous that the Islamic calendar begins from it. In Madinah the first mosque (Quba, then the Prophet's Mosque) was built and the first Muslim community established.