It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) that we prayed on a cloudy night and the direction of the qiblah was not clear to us, so we placed a marker (in the direction we had prayed). When we finished the prayer, it became clear that we had prayed toward a direction other than the qiblah. So we mentioned this to the Messenger of Allah (peace and blessings be upon him), and he (peace and blessings be upon him) said: "You did well," and he did not tell us to repeat the prayer.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2242