It is narrated from Hazrat Bara’ (may Allah be pleased with him) that when the Noble Prophet (peace and blessings be upon him) arrived in Madinah Munawwarah, we prayed facing Bayt al-Maqdis with him for sixteen (or seventeen) months. Afterwards, our direction was turned towards the Ka'bah.
Hadith Referenceمسند احمد / أول مسند الكوفيين / 18539