Mr. Sharif’s ability to deliver on any peace initiative depends largely on his relationship with the military, which recently came under strain because of the continuing treason trial of Pervez Musharraf, the former military leader.

Image Nawaz Sharif. Credit... Sang Tan/Associated Press

Mr. Modi has a poor reputation among Indian liberals and Muslims, who blame him for not acting quickly enough to stop religious riots that broke out in 2002 in Gujarat, the state he then governed. Last week, some Congress officials accused Mr. Modi of hypocrisy, but many of his critics cheered his decision to invite Mr. Sharif, and more approving messages came on Saturday after Mr. Sharif accepted.

“Very glad to hear Pak PM has accepted invite, shows that he can prevail over forces inimical to good relations with India,” Omar Abdullah, the chief minister of the Indian-administered state of Jammu and Kashmir, said in a Twitter post on Saturday. “I hope this will mark a new beginning in ties between our two countries.”

The planned meeting between Mr. Modi and Mr. Sharif on Tuesday is unlikely to result in any major decisions, and should be viewed as an “icebreaker” between the two leaders, who both run a risk by taking part, said Ashley J. Tellis, a senior associate with the Carnegie Endowment for International Peace, a research center based in Washington.

Mr. Modi’s regional foreign policy vision has economics at its core, Mr. Tellis said, and there would be a clear economic payoff to normalizing relations with Pakistan. But the new Indian leader “will not have the luxury of doing what is comfortable in his gut,” because the relationship is so strongly defined by national security issues, he said. Meanwhile, many within the political establishment may view any attempt at rapprochement with skepticism.

“There is no doubt that under the surface, there is grumbling,” Mr. Tellis said. “It tells you something about Modi, which is that if he is convinced that this is what he has to do, he really doesn’t care what the skeptics say.”