The Messenger of Allah ﷺ mentioned that he intended to perform itikaf during the last ten days of Ramadan. Ayesha asked his permission to join him in itikaf, and he granted it. Hafsa then asked Ayesha to seek permission for her as well, which she did. When Zaynab bint Jahsh saw this, she ordered a tent to be set up for her, and it was set up.She said, whenever the Messenger of Allah ﷺ finished his prayer, he would go to his own tent. He noticed the tents and asked, "What is this?"They replied, "These are the tents of Ayesha, Hafsa, and Zaynab."The Messenger of Allah ﷺ said, "Is it righteousness they intended by this? I will not perform itikaf."He returned, and when he had broken his fast, he performed itikaf for ten days in Shawwal.
أن رسول الله ﷺ ذكر أن يعتكف العشر الأواخر من رمضان، فاستأذنته عائشة فأذن لها. وسألت حفصة عائشة أن تستأذن لها، ففعلت. فلما رأت ذلك زينب بنت جحش أمرت ببناء فبني لها قالت: وكان رسول الله ﷺ إذا صلى انصرف إلى بنائه فبصر بالأبنية فقال: ما هذا. قالوا: بناء عائشة وحفصة وزينب. فقال رسول الله ﷺ: آلبر أردن بهذا؟ ما أنا بمعتكف. فرجع فلما أفطر اعتكف عشرا من شوال.
Bukhari narrated it in the Book of Itikaf (2045), and Muslim in the Book of Fasting (1172:6), both through the route of Uzai, who said, Yahya bin Saeed (he is the Ansari) narrated to me, Amra bint Abdul-Rahman narrated to me, from Ayesha, and the wording is Bukhari's. In a narration of Muslim through the route of Abu Muawiya, from Yahya bin Saeed, with the same chain. It contains, "until he performed itikaf in the first ten days of Shawwal." Malik also recorded it in the Book of Itikaf (7) from Ibn Shihab, from Amra bint Abdul-Rahman, with the same wording. Except that Yahya Laythi made an error regarding Malik's teacher, making him Ibn Shihab. The correct view is that he is Yahya bin Saeed, as will be explained later.There is nothing in the hadith that indicates an obligation to make up for itikaf on the part of someone who leaves it while it was voluntary, unlike a vow or something one has made obligatory upon oneself, in which case making it up is required. The Prophet ﷺ, if it was his habit to continue doing something once he had done it, and since he was unable to perform itikaf that year because of the large number of tents belonging to the women in the masjid, he performed itikaf in Shawwal instead.