Harm by action includes crowding someone in his space, encroaching on his seat, blocking his path, and similar conduct.
Harm by omission is to withhold something that leaves one’s Muslim brother perplexed and distressed, even though one could have helped. All such behavior is forbidden, and over it hangs the stern warning in the divine words: “Those who harm believing men and believing women for something they have not earned have surely burdened themselves with slander and a manifest sin.” The phrase “have burdened themselves” means that they have loaded upon themselves calumny—sheer falsehood—and a glaring sin, that is, a tremendous punishment; we ask Allah for safety.
Allah’s words, “for something they have not earned,” indicate that when a person is harmed for what he has earned—that is, as a lawful penalty for wrongdoing—such harm is unobjectionable. An example is His statement: “The two among you who commit it, then harm them; but if they repent and mend their ways, turn away from them.” In the early days of Islam, the one who committed the act of the people of Lot—Allah protect us—was only to be chastised until he repented. Later it was established that the Prophet ﷺ said: “Whoever you find doing the deed of the people of Lot, kill both the active and the passive partner.” Shaykh al-Islām Ibn Taymiyyah (d. 728 AH) remarked: “The Companions were unanimous that in the abomination of liwāṭ (sodomy) both the perpetrator and the partner are to be executed, though they differed over the method: some said they are to be stoned, others said they are to be thrown from the highest elevation in the town and then stoned, and others said they are to be burned. We ask Allah for well-being.”
The upshot is that harm inflicted with due right is permissible. A case in point is a man who detests the truth and goodness; when you uphold the truth and he is pained by it, that pain is harm incurred with just cause.