Explanation
Itikaf is considered to be a type of spiritual retreat. During the last 10 days of Ramadan, many Muslims spend their days and nights at the mosque (masjid) in order to ensure that they are there for whichever night Laylat al-Qadr occurs. This is called itikaf. Literally translated, it is an Arabic word that means "to isolate oneself and to stick or adhere to something."
Three Types of Itikaf
Sunnah: This is the itikaf performed during the last 10 days of Ramadan.
Nafl: Itikaf can be performed on any day/night of the year. This is considered to be a nafl (voluntary) act.
Wajib: If you have made a vow to perform itikaf, then it is compulsory (wajib) that you do so. This could be making a vow to Allah, such as through niyyat (intention) to perform itikaf or a vow based on a condition. This means saying or thinking: "If this thing happens, I will make itikaf for certain number of days."
As far as when a person should begin his or her itikaf, there seems to be a variance in opinion as well. There are a few hadiths that mention that the Prophet Muhammad (sallallahu alayhi wasallam) would begin his itikaf at the time of Maghrib prayer, and many hadiths that mention that he would begin his itikaf at the time of Fajr prayer. So it depends upon the believer and his or her intentions.
If the intention is there to do so, itikaf could last only a few hours. For example, it is encouraged, but not mandatory, to be in a state of itikaf during the time of Fajr until the sun rises and to be in a state of itikaf from Maghrib until the end of Isha prayer.
What Are the Conditions of Itikaf?
Being Muslim: The first condition to performing itikaf is that the person be Muslim. Also, note that children who have not reached an age of discernment (sin at-tamyiz) do not participate in itikaf. The child must be able to eat, dress themselves, and wash themselves without assistance. For those who follow the Hanafi school of thought, this is typically around the age of seven for boys and around the age of nine for girls.
Must be of sound mind: What this means is that a person must be able to make reasonable and rational thoughts and decisions. To explain further, a person may not be drunk or under the influence of drugs that may alter their state of mind. Also, a person who has a mental illness where they cannot make decisions on their own does not perform itikaf.
Niyyah: This means intention. One must have the intention to participate in itikaf for the sake of Allah, not for the sake of being seen by others. Your intention must be pure and focused on worshiping and pleasing Allah.
Permission: Women need to ask permission from their husbands before performing itikaf.
Performed in masjid: It is mentioned in Surat al-Baqarah 2:187 that itikaf is performed in a masjid. While some may say it is okay to perform itikaf at home, especially for women, most scholars agree that this is simply not the case at all, because the Qur'an says otherwise.
State of wudu: One must be in a state of wudu (purification/cleanliness) to participate in itikaf. If a person's wudu is nullified, such as using the bathroom, then the person must wudu before continuing itikaf. Although, if during sleep, one has what is called a wet dream, one's itikaf is not nullified but one must ghusl (full body purification) before continuing itikaf.
Fasting: By most schools of thought, fasting is a requirement to perform itikaf. Itikaf is mentioned in the Qur'an in conjunction to the fasting of Ramadan. The Prophet Muhammad (sallallahu alayhi wasallam) would always fast during the time of his itikaf. However, some believe that if a person has a medical condition, such as diabetes, that prevents him or her from fasting, that it is still permissible for that person to participate in itikaf. Please note that a medical condition differs from being ill, such as with fever or nausea.