حَدَّثَنَا مُسَدَّدٌ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، عَنْ عُبَيْدِ اللَّهِ، أَخْبَرَنِي نَافِعٌ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما ـ أَنَّ عُمَرَ، سَأَلَ النَّبِيَّ صلى الله عليه وسلم قَالَ كُنْتُ نَذَرْتُ فِي الْجَاهِلِيَّةِ أَنْ أَعْتَكِفَ لَيْلَةً فِي الْمَسْجِدِ الْحَرَامِ، قَالَ فَأَوْفِ بِنَذْرِكَ "
Narrated Ibn `Umar:
`Umar asked the Prophet (ﷺ) "I vowed in the Pre-Islamic period of ignorance to stay in I`tikaf for one night in Al-Masjid al-Haram." The Prophet (ﷺ) said to him, "Fulfill your vow."
Reference: Sahih al-Bukhari 2032
In-book : Book 33, Hadith 7
USC-MSA web (English) : Vol. 3, Book 33, Hadith 248 (deprecated)