Itikaf is a form of worship. It is formed by staying in a Mosque for a certain time. It is Ehtiyat that one should stay with the intention to worship Allah by praying formal or informal prayers although prayer is not a condition therein.
The time for this form of worship could be anytime when one is allowed to fast. The best time is the month of Ramadan, especially, the last ten days.
Conditions for I'tikaf during Ramadhan:
1. Intention as in the rest of the worship acts. It is necessary that the intention be made at the beginning of Itikaf so that the rule, requiring the worship act to be completed with intention, be followed thoroughly from the beginning to the end. The decision made at the beginning of the night to start Itikaf from the beginning of the following day will be open to objection. However, if one decides to start it from the beginning of the night it is not an offense to do so.
One is not allowed to change one's mind from one Itikaf to another of the same qualities or different.
2. Belief in Islam.
3. Freedom from mental illness.
4. Fasting; thus the Itikaf of one who cannot fast for some reason is not valid.
5. Duration; which is three continuous days at least. It could be more but not less than three days.
If it is started from the beginning of a day the two nights in between will be part of the duration. Less than three days is not considered Itikaf.
That it must take place in one of these Mosques: (a) The holy Mosque in Makkah, (b) the holy Mosque of the Prophet in Medina, (c) the holy Mosque of Kufa, (d) the holy Mosque of Basrah, and (e) the Mosque which is assigned for the Friday prayer in any town or city. It is Ehtiyat, however, to complete it in any of the first four Mosques.
The roof and basement of a Mosque is part of the same and it is valid to complete Etikaf in such places of a Mosque.
Permission of the people whose permission are required such as the master for the slave, husband and parents for the wife and children if this will be against the right of the husband or causes trouble to the parents.
6. Completing it in the Mosque where it was started. Thus, going out of the Mosque without an acceptable reason will invalidate the Itikaf, regardless, one knows the rule or is ignorant or has gone out because of forgetfulness, except in the case of an emergency or one being forced or it is because of some need such as using wash room or having Taharat.
One is allowed to come out of the Mosque during Itikaf to take part in the burial of a deceased or to visit an ailing one; Going out of the Mosque for a time long enough to cause the Itikaf to become as non-existing will be considered as invalidating the same, even if one has not done it out of one's own choice.
If one needs to have Ghusl/bath during the Itikaf and it is possible for him to have it inside the Mosque, and is not allowed to go out unless the reason for Ghusl requires him not to stay inside the Mosque.
Etikaf is originally an optional worship act but it may become obligatory because of a vow etc.
Things to avoid during Itikaf:
1. Having sex and also according to Ehtiyat kissing or playing with one's wife;
2. According to a necessary Ehtiyat causing a semen discharge,
3. And smelling perfumes for enjoyment; it is not an offense if one cannot enjoy the perfume because of some defect in his smelling ability.
4. Selling or buying in the form of a business deal, according to a necessary Ehtiyat; there is no offense to be occupied with allowable activities as sewing or writing etc., although it is a Mustahab Ehtiyat to avoid them too.
If one needs to buy something for food and there is no one to do the buying for him, it is not an offence for him to do it.
5. Expressing bitterness in talking about worldly or religious matters in order to prove one's ability, not the truth which is one of the best worships.
The contracts of buying or selling during Itikaf invalidate Itikaf, but such contracts will be valid.
If Itikaf is invalidated because of having sex even, during the night, expiation will be due; if it is invalidated by other things, there will be no expiation, although it is a Mustahab Ehtiyat in this case too.
The expiation for invalidating an Itikaf is to set free a slave or if this is not possible, fast for two consecutive months or if this also is not possible, feed sixty poor people.