Sayyiduna Mu'adh bin Jabal (may Allah be pleased with him) said: After coming to Madinah, the Messenger of Allah (peace and blessings be upon him) prayed towards Bayt al-Maqdis for sixteen months. Then Allah revealed a verse in which He commanded him (peace and blessings be upon him) to turn towards the Ka'bah, and said: "We see the turning of your face towards the heaven" [Al-Baqarah: 144], the whole verse.
Hadith Referenceالمعجم الكبير للطبراني / باب الميم / 17356