Sahih Muslim , Book 15, Hadith 4072 (USC-MSA) ⓘ
Ibn 'Umar reported that Umar (b. Khattab) said: Messenger of Allah, I had taken a vow during the days of Ignorance (Jahiliyya) that I would observe I'tikaf for a night in the Sacred Mosque. He (the Holy Prophet) said: Fulfil your vow.
حَدَّثَنَا مُحَمَّدُ بْنُ أَبِي بَكْرٍ الْمُقَدَّمِيُّ، وَمُحَمَّدُ بْنُ الْمُثَنَّى، وَزُهَيْرُ بْنُ حَرْبٍ، - وَاللَّفْظُ لِزُهَيْرٍ - قَالُوا حَدَّثَنَا يَحْيَى، - وَهُوَ ابْنُ سَعِيدٍ الْقَطَّانُ - عَنْ عُبَيْدِ اللَّهِ، قَالَ أَخْبَرَنِي نَافِعٌ، عَنِ ابْنِ عُمَرَ، أَنَّ عُمَرَ، قَالَ يَا رَسُولَ اللَّهِ إِنِّي نَذَرْتُ فِي الْجَاهِلِيَّةِ أَنْ أَعْتَكِفَ لَيْلَةً فِي الْمَسْجِدِ الْحَرَامِ . قَالَ " فَأَوْفِ بِنَذْرِكَ " .
also referenced under: Book 27, Hadith 40 (In-Book) & Hadith 1656 (Reference)