The change of the Qibla to the Sacred Mosque
After sixteen months of praying toward Jerusalem, Allah's command came to turn the Qibla to the noble Kaʿba in answer to the Prophet's ﷺ longing: "So turn your face toward the Sacred Mosque." Thus the Ummah was distinguished by its own Qibla.
In Makkah the Prophet ﷺ prayed toward Jerusalem with the Kaʿba before him. After the Hijra he prayed toward Jerusalem for sixteen months, longing to be turned to the Kaʿba, the Qibla of his father Ibrahim, and turning his face toward the sky in hope and expectation.
Then the verses were revealed: "We have certainly seen the turning of your face toward the sky, so We will surely turn you to a Qibla with which you will be pleased. So turn your face toward the Sacred Mosque." He ﷺ turned in the prayer, and a man came to people praying ʿAsr — in a report, to the people of Qubaʾ at Fajr — and said: I bear witness that I prayed with the Messenger of Allah toward Makkah, so they turned, as they were, toward the Kaʿba.
The Jews and hypocrites raised an outcry: What turned them from their former Qibla? So Allah revealed: "Say: To Allah belong the East and the West." The mosque in which the change occurred was named the Mosque of the Two Qiblas, and the Kaʿba became the unifying Qibla of the Muslims forever.
Note — differing reports on the date: The well-known view is that the change was in mid-Shaʿban 2 AH, two months before Badr; some say in Rajab. The difference is old among the biographers.