Ayesha reported,

The scholars act upon this, that when a man performs itikaf, he should not leave his place of seclusion except to attend to human necessity. They are unanimous that he may go out to relieve himself, for defecation and urination.The scholars then differed regarding visiting the sick, attending the Friday prayer, and attending funerals for the one in itikaf. Some of the scholars, among them companions of the Prophet ﷺ and others, held that he may visit the sick, accompany funeral processions, and attend the Friday prayer if he stipulated that condition. This is the view of Sufyan Thawri and Ibn Mubarak.Others said he may not do any of these things. They held that if the one performing itikaf is in a city where the Friday prayer is held, he should perform itikaf only in the congregational mosque, because they disliked his leaving his place of seclusion for the Friday prayer, yet they did not allow him to omit the Friday prayer. So they said he should perform itikaf only in the congregational mosque, so that he would not need to leave his seclusion except for human necessity, since leaving for anything other than human necessity invalidates the itikaf in their view. This is the view of Malik and Shafii.Ahmad said he should not visit the sick nor follow funeral processions, based on the hadith of Ayesha.Ishaq said that if he stipulated that condition, he may follow funeral processions and visit the sick.

Tirmidhi 805

Sahih

حدثنا بذلك قتيبة حدثنا الليث بن سعد عن ابن شهاب عن عروة وعمرة

عن عائشة

والعمل على هذا عند أهل العلم إذا اعتكف الرجل أن لا يخرج من اعتكافه إلا لحاجة الإنسان واجتمعوا على هذا أنه يخرج لقضاء حاجته للغائط والبول ثم اختلف أهل العلم في عيادة المريض وشهود الجمعة والجنازة للمعتكف فرأى بعض أهل العلم من أصحاب النبي ﷺ وغيرهم أن يعود المريض ويشيع الجنازة ويشهد الجمعة إذا اشترط ذلك وهو قول سفيان الثوري وابن المبارك و قال بعضهم ليس له أن يفعل شيئا من هذا ورأوا للمعتكف إذا كان في مصر يجمع فيه أن لا يعتكف إلا في مسجد الجامع لأنهم كرهوا الخروج له من معتكفه إلى الجمعة ولم يروا له أن يترك الجمعة فقالوا لا يعتكف إلا في مسجد الجامع حتى لا يحتاج أن يخرج من معتكفه لغير قضاء حاجة الإنسان لأن خروجه لغير حاجة الإنسان قطع عندهم للاعتكاف وهو قول مالك والشافعي و قال أحمد لا يعود المريض ولا يتبع الجنازة على حديث عائشة و قال إسحق إن اشترط ذلك فله أن يتبع الجنازة ويعود المريض

الترمذي 805صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Fasting
Chapter
One observing itikaf going out for his needs or not
Numbering
Darussalam 805
Tirmidhi 805