Umar said, "Messenger of Allah, during the days of ignorance I vowed to spend a night in spiritual retreat in the Sacred Mosque."He replied, "Then fulfill your vow."
أن عمر قال: يا رسول الله، إني نذرت في الجاهلية أن أعتكف ليلة في المسجد الحرام؟ قال: فأوف بنذرك
Bukhari related it in itikaf (2032) and Muslim in oaths and vows (16:1656:27), both through Yahya bin Saeed Qattan, from Ubaydullah, "Nafi told me, from Ibn Umar," and he mentioned it.