The Prophet ﷺ said, "Allah wrote a book two thousand years before He created the heavens and the earth, and from it He sent down two verses with which He concluded Surat al-Baqarah. They are not recited in any house for three nights without a devil being kept far from it."
حدثنا محمد بن بشار حدثنا عبد الرحمن بن مهدي حدثنا حماد بن سلمة عن أشعث بن عبد الرحمن الجرمي عن أبي قلابة عن أبي الأشعث الجرمي
عن النبي ﷺ قال إن الله كتب كتابا قبل أن يخلق السموات والأرض بألفي عام أنزل منه آيتين ختم بهما سورة البقرة ولا يقرأان في دار ثلاث ليال فيقربها شيطان
Its isnad is hasan. Nasai narrated it in Amal al-Yawm wal-Layla, no. 967, from the hadith of Hammad bin Salama with the same wording. Ibn Hibban graded it sahih, no. 1726, as did Hakim, 1/562 and 2/260, and Dhahabi agreed with him. The hadith has a defect, but it is not one that undermines it.