It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) prayed in Makkah facing Bayt al-Maqdis (Jerusalem), while the Ka'bah was in front of him (peace and blessings be upon him), and also for sixteen months after he emigrated to Madinah (he continued to pray in this way); then he (peace and blessings be upon him) was turned towards the Ka'bah.
There is a supporting narration (shahid) for it in the two Sahihs through Ibn Ishaq from the hadith of Sayyiduna al-Bara' bin Azib (may Allah be pleased with him).