Self-flagellation is forbidden (Haram) in Islam. Great Shia scholars such as grand Ayatullah Khamenei who is the leader of Islamic Republic of Iran and Ayatullah Sistani, the Shia Leader in Iraq, have prohibited any self-mutilation such as self-flagellation with knives or chains (Tatbir) and even walking on fire. You can see their Fatwas (religious opinions) on tatbir.org
“Practicing Tatbir (i.e.self-flagellation) is one of the wrongdoings. I know that some people would say: “It was better for him not to mention Tatbir.” They would say: “Why do you bother with Tatbir? Some people do it, let them do!”. No! it’s not right to remain silent toward such a wrong action…
It is wrong that some people hold daggers and hit themselves on the head to bleed. What are they seeking?! How can this be an act of mourning?! Of course hitting on the head with one’s hands is a sign of mourning. You have seen it several times that when people face suffering, they hit on their chests and heads. This is a typical symbol of mourning. But where have you ever seen a person who is suffering from the loss of a dear one, hit on their head with a dagger and make it bleed?! How can this be an act of mourning?
Tatbir is a fabricated tradition. It is among the issues that does not belong to the religion and undoubtedly God is not also pleased with such a practice.
The more I thought about it, the more truly I realized I cannot overlook informing our dear people about Tatbir which is certainly an act of wrongdoing and a heresy. Do not practice it! I do not approve of it. If someone does something to pretend that they want to practice Tatbir, I will be truly dissatisfied with them. I am declaring this solemnly.”
-Imam Khamenei’s saying in 1994
The following questions are also replied by Grand Ayatullah Khamenei :
Question 1449: In commemorating the martyrdom of Imam Husayn (PBUH) on the tenth of Muharram, some people hit themselves with a machete, or walk bare-footed on fire. Such actions defame Shi‘ism and put it in a bad light, if not undermine it. They cause bodily and spiritual harms on these doing it as well. What is your opinion in this matter?
Answer: Any practice that causes bodily harm, or leads to defaming the faith, is haram(forbidden). Accordingly, the believers have to steer clear of it. There is no doubt that many of these practices besmirch the image of Ahlul Bayt’s (PBUH) School of Thought which is the worst damage and loss.
Question 1450: Is hitting oneself with swords halal (allowed) if it is done in secret? Or is your fatwa in this regard universal?
Answer: “In addition to the fact that it is not held in the common view as manifestations of mourning and grief and it has no precedent at the lifetime of the Imams (a.s.) and even after that and we have not received any tradition quoted from the Infallibles (a.s.) about any support for this act, beit privately or publicly, this practice would, at the present time, give others a bad image of our school of thought. Therefore, there is no way that it can be considered permissible.”