Omar Rivera was charged with criminal trespass after worshippers at the Al-Iman Mosque on Steinway Street subdued him Wednesday night.
Holding a beer bottle, Rivera burst in during evening prayers. He allegedly shouted anti-Muslim slurs, calling the worshipers "terrorists," then flashed his middle finger and urniated outside the mosque.
Two worshipers subdued him and called 911.
Rivera was charged and taken to a hospital for psychiatric evaluation.
The mosque said earlier news reports that the suspect urinated on prayer rugs was not inaccurate.