It is narrated from Hazrat Sa'id bin Musayyib that the Messenger of Allah (peace be upon him) offered prayers facing Bayt al-Maqdis for sixteen months after coming to Madinah, then the Qiblah was changed two months before the Battle of Badr.
Hadith Referenceموطا امام مالك رواية يحييٰ / كتاب القبلة / 460