Wa `Alaykum As-Salaam Waramatullah Wabarakatuh !
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah and peace and blessings be upon His Messenger.
Dear brother in Islam, we really appreciate your forwarding this question to us, and we commend the keenness you show in getting acquainted with the teachings of Islam; may Allah Almighty help us stick to His Right Path.
As regards your question, Muslim jurists maintain that wet dream does not vitiateI`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.
Shedding more light on this issue, we cite the following from The Kuwaiti Encyclopedia of Islamic Jurisprudence:
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 perfom dry ablution.
As regards counting the time spent in performing the bath as part of the time ofI`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.
Allah Almighty knows best.