That 'Umar said: Messenger of Allah, I took a vow in pre-Islamic times that I would stay in the sacred mosque (Masjid Haram) as a devotion (i'tikaf). The Prophet (ﷺ) said: Fulfill your vow.
Sunan Abi Dawud Book 22, Hadith 84