(afp) -- Modi's remarks -- his first on vigilantism in nearly a year -- come just days after a Muslim teenager was stabbed to death on a train after being accused of carrying beef.
"Killing people in the name of Gau Bhakti (cow worship) is not acceptable. This not something Mahatma Gandhi would approve," Modi said.
India has been reeling from a spate of vigilante murders in recent months, targeting Muslims and low caste Hindus accused of killing cows or consuming beef.
In the latest high-profile incident, 15-year-old Junaid Khan and three of his brothers were attacked last week in an apparent row over seats as they travelled home by train from New Delhi.
Police have arrested four men over the attack.
One of Khan's brothers said the attackers accused them of carrying beef, a meat popular among many Indian Muslims and low caste Dalits, but shunned by most upper caste Hindus.
Khan's murder drew thousands to the streets across Indian cities on Wednesday, with demonstrators calling for an end to the wave of mob violence under the slogan "not in my name".
Modi expressed his "pain and anguish at the current environment" in India, listing incidents of vigilante violence.
"No person in this nation has the right to take the law in his or her own hands in this country. Violence never has and never will solve any problem," he said.
Rights groups have warned of a culture of impunity for crimes committed against Muslims and urged Modi's Hindu nationalist government to act.