Sahih Muslim, Book 27, Hadith 39 (Muslim 4253)

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.