Narrated from Sayyiduna Bara bin Azib (may Allah be pleased with him) that when the Noble Prophet (peace and blessings of Allah be upon him) migrated to Madinah, he first stayed with his maternal or paternal relatives who were from the Ansar. After arriving in Madinah, the Prophet (peace be upon him) prayed facing Bayt al-Maqdis for sixteen or seventeen months, but he preferred that his Qiblah be towards the Ka'bah (and so it happened). The very first prayer that the Prophet (peace be upon him) offered facing the Ka'bah was the 'Asr prayer, and some people joined him in that prayer. One of them left and passed by a mosque where he saw people praying facing Bayt al-Maqdis, so he said, "I bear witness before Allah that I have prayed with the Messenger of Allah (peace be upon him) facing Makkah." (Upon hearing this) those people turned towards the Ka'bah in the same state they were in. When the Prophet (peace be upon him) used to pray facing Bayt al-Maqdis, the Jews and all the People of the Book were very pleased, but when the Prophet (peace be upon him) turned his face towards the Ka'bah, it was very displeasing to them.