It is a lonely feeling to know that your country’s leaders do not want you. To be vilified because you are a Muslim in what is now a largely Hindu-first India.

It colors everything. Friends, dear for decades, change. Neighbors hold back from neighborly gestures — no longer joining in celebrations, or knocking to inquire in moments of pain.

“It is a lifeless life,” said Ziya Us Salam, a writer who lives on the outskirts of Delhi with his wife, Uzma Ausaf, and their four daughters.

When he was a film critic for one of India’s main newspapers, Mr. Salam, 53, filled his time with cinema, art, music. Workdays ended with riding on the back of an older friend’s motorcycle to a favorite food stall for long chats. His wife, a fellow journalist, wrote about life, food and fashion.

Now, Mr. Salam’s routine is reduced to office and home, his thoughts occupied by heavier concerns. The constant ethnic profiling because he is “visibly Muslim” — by the bank teller, by the parking lot attendant, by fellow passengers on the train — is wearying, he said. Family conversations are darker, with both parents focused on raising their daughters in a country that increasingly questions or even tries to erase the markers of Muslims’ identity — how they dress, what they eat, even their Indianness altogether.

One of the daughters, an impressive student-athlete, struggled so much that she needed counseling and missed months of school. The family often debates whether to stay in their mixed Hindu-Muslim neighborhood in Noida, just outside Delhi. Mariam, their oldest daughter, who is a graduate student, leans toward compromise, anything to make life bearable. She wants to move.

Anywhere but a Muslim area might be difficult. Real estate agents often ask outright if families are Muslim; landlords are reluctant to rent to them.

“I have started taking it in stride,” Mariam said.

“I refuse to,” Mr. Salam shot back. He is old enough to remember when coexistence was largely the norm in an enormously diverse India, and he does not want to add to the country’s increasing segregation.

But he is also pragmatic. He wishes Mariam would move abroad, at least while the country is like this.

Mr. Salam clings to the hope that India is in a passing phase.

Prime Minister Narendra Modi, however, is playing a long game.

His rise to national power in 2014, on a promise of rapid development, swept a decades-old Hindu nationalist movement from the margins of Indian politics firmly to the center. He has since chipped away at the secular framework and robust democracy that had long held India together despite its sometimes explosive religious and caste divisions.

Right-wing organizations began using the enormous power around Mr. Modi as a shield to try to reshape Indian society. Their members provoked sectarian clashes as the government looked away, with officials showing up later to raze Muslim homes and round up Muslim men. Emboldened vigilante groups lynched Muslims they accused of smuggling beef (cows are sacred to many Hindus). Top leaders in Mr. Modi’s party openly celebrated Hindus who committed crimes against Muslims.

On large sections of broadcast media, but particularly on social media, bigotry coursed unchecked. WhatsApp groups spread conspiracy theories about Muslim men luring Hindu women for religious conversion, or even about Muslims spitting in restaurant food. While Mr. Modi and his party officials reject claims of discrimination by pointing to welfare programs that cover Indians equally, Mr. Modi himself is now repeating anti-Muslim tropes in the election that ends early next month. He has targeted India’s 200 million Muslims more directly than ever, calling them “infiltrators” and insinuating that they have too many children.

This creeping Islamophobia is now the dominant theme of Mr. Salam’s writings. Cinema and music, life’s pleasures, feel smaller now. In one book, he chronicled the lynchings of Muslim men. In a recent follow-up, he described how India’s Muslims feel “orphaned” in their homeland.

“If I don’t pick up issues of import, and limit my energies to cinema and literature, then I won’t be able to look at myself in the mirror,” he said. “What would I tell my kids tomorrow — when my grandchildren ask me what were you doing when there was an existential crisis?”

As a child, Mr. Salam lived on a mixed street of Hindus, Sikhs and Muslims in Delhi. When the afternoon sun would grow hot, the children would move their games under the trees in the yard of a Hindu temple. The priest would come with water for all.

“I was like any other kid for him,” Mr. Salam recalled.

Those memories are one reason Mr. Salam maintains a stubborn optimism that India can restore its secular fabric. Another is that Mr. Modi’s Hindu nationalism, while sweeping large parts of the country, has been resisted by several states in the country’s more prosperous south.

Family conversations among Muslims there are very different: about college degrees, job promotions, life plans — the usual aspirations.

In the state of Tamil Nadu, often-bickering political parties are united in protecting secularism and in focusing on economic well-being. Its chief minister, M.K. Stalin, is a declared atheist.

Jan Mohammed, who lives with his family of five in Chennai, the state capital, said neighbors joined in each other’s religious celebrations. In rural areas, there is a tradition: When one community finishes building a place of worship, villagers of other faiths arrive with gifts of fruits, vegetables and flowers and stay for a meal.

“More than accommodation, there is understanding,” Mr. Mohammed said.

His family is full of overachievers — the norm in their educated state. Mr. Mohammed, with a master’s degree, is in the construction business. His wife, Rukhsana, who has an economics degree, started an online clothing business after the children grew up. One daughter, Maimoona Bushra, has two master’s degrees and now teaches at a local college as she prepares for her wedding. The youngest, Hafsa Lubna, has a master’s in commerce and within two years went from an intern at a local company to a manager of 20.

Two of the daughters had planned to continue on to Ph.D’s. The only worry was that potential grooms would be intimidated.

“The proposals go down,” Ms. Rukhsana joked.

A thousand miles north, in Delhi, Mr. Salam’s family lives in what feels like another country. A place where prejudice has become so routine that even a friendship of 26 years can be sundered as a result.

Mr. Salam had nicknamed a former editor “human mountain” for his large stature. When they rode on the editor’s motorcycle after work in the Delhi winter, he shielded Mr. Salam from the wind.

They were together often; when his friend got his driver’s license, Mr. Salam was there with him.

“I would go to my prayer every day, and he would go to the temple every day,” Mr. Salam said. “And I used to respect him for that.”

A few years ago, things began to change. The WhatsApp messages came first.

The editor started forwarding to Mr. Salam some staples of anti-Muslim misinformation: for example, that Muslims will rule India in 20 years because their women give birth every year and their men are allowed four wives.

“Initially, I said, ‘Why do you want to get into all this?’ I thought he was just an old man who was getting all these and forwarding,” Mr. Salam said. “I give him the benefit of doubt.”

The breaking point came two years ago, when Yogi Adityanath, a Modi protégé, was re-elected as the leader of Uttar Pradesh, the populous state adjoining Delhi where the Salam family lives. Mr. Adityanath, more overtly belligerent than Mr. Modi toward Muslims, governs in the saffron robe of a Hindu monk, frequently greeting large crowds of Hindu pilgrims with flowers, while cracking down on public displays of Muslim faith.

On the day of the vote counting, the friend kept calling Mr. Salam, rejoicing at Mr. Adityanath’s lead. Just days earlier, the friend had been complaining about rising unemployment and his son’s struggle to find a job during Mr. Adityanath’s first term.

“I said, ‘You have been so happy since morning, what do you gain?’” he recalled asking the friend.

“Yogi ended namaz,” the friend responded, referring to Muslim prayer on Fridays that often spills into the streets.

“That was the day I said goodbye,” Mr. Salam said, “and he hasn’t come back into my life after that.”