Q: What should a person do if he had a wet dream in the masjid?

A: He should immediately leave the masjid to perform ghusl.
ولو احتلم فيه إن خرج مسرعاً تيمّم ندباً وإن مكث لخوفٍ فوجوباً ولايصلى ولايقرأ (الدر المختار مع رد المحتار 1/172, حاشية الطحطاوى 144)
Answered by:
Checked & Approved:
Ihyaaud Deen An Effort to Revive Deen in Totality