Clashes broke out at some early protests, but more recent demonstrations have been peaceful, deliberately drawing on Gandhi’s example of nonviolent resistance. The government has responded with both force and a virulent disinformation campaign. (Officials have denied cracking down on peaceful protests, despite many images and witness accounts of violence.)

In recent days, a protest camp of hundreds of women in the Shaheen Bagh neighborhood of New Delhi has come to symbolize the movement. Officials have said the women are radicals or have been paid to be there, and many believe a police crackdown is imminent.

Throughout his six years in power, Mr. Modi has frequently linked himself to Gandhi’s legacy, saying he was “made of the same soil” as the champion of Indian independence. His vice president has called it “divine coincidence” that both men were born in the state of Gujarat. Mr. Modi has even used Gandhi’s signature round, wire-rimmed spectacles as a logo for his “Clean India” sanitation campaign.

Mr. Modi has also drawn on Gandhi’s globally resonant image overseas as he cuts military alliances and trade deals. In October, as he wrapped up meetings at the United Nations General Assembly, he wrote an Opinion piece for The New York Times calling on the world to learn from Gandhi’s teachings.

But one fact omitted by the prime minister was that Gandhi was killed by a Hindu nationalist — a man nurtured by the same hard-line ideological group that shaped Mr. Modi: the Rashtriya Swayamsevak Sangh.

The assassin, Nathuram Godse, believed that Gandhi had betrayed Hindus by being too conciliatory to Muslims. That line is still echoed today by Mr. Modi’s party, the Bharatiya Janata Party, which is filled with officials who revere Godse and see Gandhi as a traitor.