The person broke the law and police went to arrest him.
Perfectly legal
The villagers tried to stop police. Illegal under Section 353 of IPC.
353. Assault or criminal force to deter public servant from discharge of his duty.—Whoever assaults or uses criminal force to any person being a public servant in the execution of his duty as such public servant, or with intent to prevent or deter that person from discharging his duty as such public servant, or in consequence of anything done or attempted to be done by such person in the lawful discharge of his duty as such public servant, shall be punished with imprisonment of either description for a term which may extend to two years, or with fine, or with both.