“This is a once-in-a-generation opportunity to begin fresh and build a level of trust that needs to be developed to define relations for the next 50 years,” said Sridhar K. Khatri, former executive director of the South Asia Center for Policy Studies in Katmandu.

A last-minute dispute over the wording of a major hydropower development agreement meant that the two sides signed only minor agreements on Sunday. But there is considerable hope that the power deal will materialize.

“His visit has brought great hope,” Ayush Shrestha, a 29-year-old marketing executive, said at a Katmandu restaurant. “It has led even our own political parties to sit down, put aside their differences and discuss the agenda with Modi.”

Mr. Modi was elected in May with the biggest majority in Parliament and the highest hopes for transforming India showered on any leader in 30 years. Domestically, his tentative legislative steps since then have disappointed some supporters, but his outreach to India’s long-ignored neighbors has received almost universal praise. South Asia is one of the world’s poorest and least integrated regions in the world, and India’s longtime preoccupation with domestic matters is partly to blame.

In recent years, China has stepped into the vacuum left by India, leading New Delhi to assume responsibilities in its own neighborhood. In a first for an Indian prime minister, Mr. Modi invited to his inauguration the other members of the South Asian Association for Regional Cooperation, a group of eight countries, including Pakistan, its longtime foe. Mr. Modi first visited Bhutan and is soon headed to Sri Lanka.

“The warm embrace Modi has received in Nepal raises the question of whether China is really the threat to India’s influence that some feared,” Ms. Kripalani said.

It is unclear whether Mr. Modi’s visit will inspire political compromise in Nepal, where legislative acrimony is a constant. A 10-year insurgency ended in 2006, but a resulting Constituent Assembly failed after four years of effort to write a Constitution. Paralysis ensued until elections in November led to the rout of the dominant Maoist parties.