NEW DELHI — In the lush garden of Hyderabad House, President Trump and Prime Minister Narendra Modi celebrated their friendship and talked of a modern, diverse and unified India. Across town, an explosion of anger over Mr. Modi’s sectarian policies set a neighborhood on edge, leaving a trail of dead bodies and a widening religious rift.

The two sides of New Delhi on display on Tuesday underscored the disparity between the hopes of Mr. Trump’s trip and the tensions outside the fortified environs of world leaders. Just miles from the pomp of a presidential visit, a mob of hot-tempered Hindu men wielding iron bars hunted their Muslim neighbors on streets littered with scraps of bricks.

As he completed his two-day stay, Mr. Trump focused only on the positive, offering validation of Mr. Modi as a champion of religious liberty even as the Indian government has adopted Hindu-first policies targeting Muslims. The president publicly accepted Mr. Modi’s word that he treats the 1.3 billion people in his diverse country fairly without regard to faith and made no mention of the months of protests by those who think otherwise.

“We did talk about religious freedom, and I will say that the prime minister was incredible on what he told me,” Mr. Trump told reporters. “He wants people to have religious freedom, and very strongly.”