As they clasped hands while walking down the red carpet at the Lahore airport recently, Nawaz Sharif of Pakistan and Narendra Modi of India looked more like close friends than the leaders of two countries whose tense relations have long been a threat to regional stability.

Mr. Modi’s visit to Pakistan was arranged on short notice and marked the first visit by an Indian prime minister in almost 12 years. Mr. Sharif’s warm greeting and hosting of Mr. Modi at the Sharif family home set a welcome atmosphere for talks aimed at resuming a stalled dialogue on critical economic and security issues. But while the two leaders got the political optics right, the challenge, as always, will be overcoming formidable obstacles at home.

Mr. Sharif has pressed for engagement with India; Mr. Modi has been conflicted. He invited Mr. Sharif to his inauguration last year but soon after canceled high-level talks, annoyed that Pakistani diplomats had met with separatist leaders from disputed Kashmir. Mr. Modi has also taken a harder line than his predecessor on security issues involving Pakistan.

Domestic constraints limit both leaders, especially Mr. Sharif. His power is eclipsed by an army that controls the fastest-growing nuclear weapons program in the world and has long played a double game of taking American assistance while supporting the Taliban in Afghanistan as well as militants opposed to India.

The army exploits tensions with India to bolster its importance in Pakistan. Whether the generals support Mr. Sharif’s new outreach to Mr. Modi is unclear, though it seems clear that contact between the two nuclear-armed countries is imperative given the many points of friction, including Afghanistan and Kashmir.

Mr. Modi seems to have finally decided that better relations are not only necessary, but require his personal involvement. He may also have concluded that improved ties with Pakistan could help him realize his domestic ambitions, which include transforming India into an economic power. So far he has not delivered on that promise, spurring protests by middle-class Indians demanding more good jobs.

Meanwhile, members of his government and political party have been inflaming sectarian tensions, alarming many Indians and damaging Mr. Modi’s international reputation. A recent report by the Council on Foreign Relations concluded that without market reforms India risks being left behind in international trade, and that the risk of conflict with Pakistan “threatens to drag India down.” The group said India should seek better relations “for the sake of its own future.”

One major test of the Modi-Sharif relationship will be whether the two can work together to promote peace talks between the Afghan government and the Taliban, which has been making gains on the battlefield. Pakistan has given assistance and a haven to the Afghan Taliban as a hedge against India, while India has supported and provided military assistance to the Afghan government.

American officials say they believe that Pakistan’s army has become more serious about fighting the Taliban and encouraging peace talks because the generals are increasingly worried that a Taliban victory could make Afghanistan a more attractive magnet for the Islamic State and other militants who could threaten Pakistan. Other experts are doubtful. Whether a stronger personal connection between Mr. Modi and Mr. Sharif can lead to real trust and cooperation on such issues remains to be seen.

Courtesy NY Times