Conditions of Itikaf (Part 4)
Leaving the Masjid during the Period of Itikaf
It is not permissible to leave the Masjid during the state of Itikaf except for a reason and necessity which would (a) be a logical and reasonable excuse; (b) be deemed so according to the general population and (c) the religious rules of Islam dictate.
Thus, in the following examples, it would be permitted to leave the Masjid while in the state of Itikaf: going to a doctor in cases of emergency, going to the bathroom (as these are logical reasons), visiting someone who is very sick and taking part in the burial rites of a person IF the person who has passed away was a close relation to the person performing Itikaf (which would be a necessity deemed so by the general consensus and population), or to perform a Ghusl (if needed) or to do Wudhu (which are necessities which the religion dictates).
Leaving the Masjid for classes (school) or for study sessions with a study partner or for Tablegh and propagation of the faith and other things such as this is not permissible as they do not fall into any of the three categories mentioned above (since when a person makes the intention to perform Itikaf he has also taken into consideration that he will not be attending school and has made the necessary arrangements before hand. Similarly, the one engaged in Itikaf knows from before hand that if his ‘field of work’ is Tablegh, that he would be disconnecting himself from that ‘job’ for this period). If a person performs his Itikaf in a place in which another person was already in Itikaf (but had left for a brief moment) however he has left his prayer mat or other signs that he was coming back to that spot, then the second person must leave that area, otherwise he would be considered as a usurper of that piece of land where he is performing his Itikaf. His Itikaf would be correct if he continues to stay there however he would have committed a sin. If a person in Itikaf has a wet dream and needs to perform a Ghusl, however it is not possible to do this in the Masjid (or its compound), it is obviously obligatory upon him to leave the Masjid and his Itikaf will be considered null and void. The same rule applies to sisters who are not able to stay inside the Masjid due to their monthly cycle since they are not permitted to stay inside a Masjid, they too must immediately leave the Masjid and for them too, their Itikaf is null and void. According to obligatory precaution, if a person leaves the Masjid for a necessity, he must choose the shortest and closest route to leave and return by and it is obligatory that he does not keep himself out of the Masjid for more than the needed time period. It is also obligatory that he does not sit underneath an area which shades him. Rather, according to precaution, it is not permitted for him to sit outside of the Masjid except for cases of necessity.

If the person performing Itikaf leaves the Masjid in order to complete a necessity upon him, and the time period which he leaves the Masjid for is a very long one such as that people would doubt or not consider him being in a state of Itikaf, then his Itikaf would be null and void.
Penitence for Breaking the Rules of the Itikaf
In some instances, if a person does one of the things which break his state of Itikaf, he must offer penitence. Some examples of this are mentioned as follows:
1. If a person has sexual relations during the period of Itikaf and Itikaf was wajib for him to perform (due to a promise, oath, etc… which he made), then he must make up the Itikaf by performing it properly at a later date.
2. If a person performs one of the other things which makes Itikaf void and his Itikaf was obligatory (due to a promise, oath, etc… which he made), then he must finish the time remaining of Itikaf and redo it later on.
3. If Itikaf was not obligatory and if a person does something on the first day of Itikaf then he must immediately come out of this state, however if it is on the third day then he must finish the period remaining.
4. If a person performs one of the other things which makes Itikaf void and his Itikaf was a recommended one and this happens after the second day, then he must redo the Itikaf later on, however if it is before the end of the second day, then he has no responsibility on him to redo it.
Source: coiradio.com
Other links:
Itikaf, the Spring of Life
What is the manner of washing face, wiping head and feet in wudhu?
What Is The Philosophy Behind (The Payment) Of Zakaat?
What Is The Philosophy Behind Tayammum ?
Why does Zakat become Wajib?