Bulugh al-Maram, Book 13, Hadith 1396 (English)

Narrated 'Umar (RA): [concerning his consultation with the Prophet] He said: I said: O Allah's Messenger, I made a vow in the Jahiliyya times to spend a night in devotion (I'tikaf) in the Sacred Mosque. He (the Prophet) said: "Fulfill your vow." [Agreed upon]. al-Bukhari added in another narration: "Then, spend a night in devotion (in the Sacred Mosque)."

وَعَنْ عُمَرَ ‏- رضى الله عنه ‏- قَالَ: { قُلْتُ: يَا رَسُولَ اَللَّهِ! إِنِّي نَذَرْتُ فِي اَلْجَاهِلِيَّةِ; أَنْ أَعْتَكِفَ لَيْلَةً فِي اَلْمَسْجِدِ اَلْحَرَامِ.‏ قَالَ: "فَأَوْفِ بِنَذْرِكَ" } مُتَّفَقٌ عَلَيْهِ 1‏ وَزَادَ اَلْبُخَارِيُّ فِي رِوَايَةٍ 2‏ { فَاعْتَكَفَ لَيْلَةً } 3‏.‏ ‏1 ‏- صحيح.‏ رواه البخاري ( 2032 )‏، ومسلم ( 1656 )‏.‏‏2 ‏- ووقع في "أ" : "روايته".‏‏3 ‏- البخاري ( 2042 )‏.‏

sunnah.com

also referenced under: Book 13, Hadith 23 (In-Book)