Muslim jurists maintain that wet dream does not vitiate I`tikaf, just as it does not invalidate fasting, for the Prophet, peace and blessings be upon him, says, “The following three do not invalidate fasting: cupping, vomiting and wet dream.”
Besides, such thing as wet dream is something beyond man’s control. Thus, on having wet dream while in I`tikaf one just have to perform major impurity bath and continue the act of worship.
As for performing this bath, it’s controversial whether it should be performed in the mosque or outside it; the one preferable is that if performing this bath will not affect the purity of the mosque, that is okay, and such thing is very easy nowadays.
The Kuwaiti Encyclopedia of Islamic Jurisprudence, states that: Ulama unanimously agreed that I`tikaf is never vitiated by having wet dream, or by going out of the mosque to perform the major impurity bath, except in one case, that is, as mentioned by the Hanafites, if it’s possible for a person to perform the bath inside the mosque, without the fear that this might deplete the purity of the mosque. Other Ulama differed on this; some of them maintain that it’s permissible for one to perform the major impurity bath outside the mosque even if it’s guaranteed that performing that bath inside the mosque won’t pollute it; some scholars even maintain that it’s obligatory in I`tikaf to get out of the mosque and perform the major impurity bath; i.e. one should by no means do that in the mosque. If such a person finds it difficult to go out of the mosque, he can perform dry ablution.
As regards counting the time spent in performing the bath as part of the time of I`tikaf this is controversial among Ulama, Shafites, Malikites and Hanafites, maintain that time spent in doing that will not be counted as part of I`tikaf, but the Hanabaites say that time spent on purifying oneself and having major impurity bath will be counted as part of I`tikaf.