During his visit to Japan last week, Prime Minister Manmohan Singh underscored two golden rules of diplomacy. One is to seize the moment when there is an opportunity to advance. The other is to stand by friends through thick and thin. In the coming weeks, Singh will have to demonstrate a vigorous commitment to these principles in India's engagement with two of its most important neighbors, Pakistan and Bangladesh.

The swearing in of Nawaz Sharif as the prime minister this week opens the door for a fresh start with Pakistan. As the current tenure of Sheikh Hasina comes to an end (elections are due any time from October 2013) in Bangladesh, the window for a historic consolidation of bilateral relations between Delhi and Dhaka might soon close.

Overruling fears in Delhi about annoying Beijing, Singh outlined an ambitious agenda for a strategic partnership with Japan. Delhi would have had little diplomatic credibility, least of all with Beijing, if Singh had chosen to abandon the special relationship with Japan's premier, Shinzo Abe, in the elusive search for an accommodation with China's new leaders. He must now show equal resolve in reaching out to Nawaz Sharif of Pakistan and keeping his word to Prime Minister Sheikh Hasina in Bangladesh. Some of the PM's boldest diplomatic moves during the last nine years of his premiership have been towards Pakistan and Bangladesh. He must now pick up the threads of the peace process with Islamabad, and finish what he started with Dhaka.

In the UPA's first term, Singh built on his predecessor, Atal Bihari Vajpayee's bold agenda towards Pakistan. He came close to clinching agreements on such difficult issues as Siachen and Sir Creek, and exploring a framework of settlement on Jammu & Kashmir.

Two factors, however, undermined Singh's effort at normalizing bilateral relations with Pakistan. One was internal: the PM's timid colleagues in the Congress party had no stomach for bold moves towards Pakistan (or towards any other country, for that matter). The other was external: while cross-border terrorism cast a shadow over the peace process with Pakistan, the outrageous attack on Mumbai at the end of November 2008 took away the political oxygen by the end of the UPA's first term. In his second tenure as PM, Singh sought to renew the peace process; but it never acquired the necessary momentum despite support from Pakistan's civilian leadership led by Asif Ali Zardari.

If advance on the Pakistan front remained difficult, Bangladesh presented a historic opportunity in the UPA's second term after Sheikh Hasina's return to power on a sweeping mandate at the end of 2009. Singh and Hasina outlined an ambitious bilateral agenda and ordered their senior officials to resolve all outstanding bilateral issues.

In the case of Pakistan, state support to terrorism prevented the possibilities for big advances on the rest of the relationship. In contrast, Hasina's crackdown on the sources of anti-India terrorism enabled advances on many fronts. Dhaka's unilateral actions on terrorism saw Delhi respond with expansive market access to goods from Bangladesh. Singh and Hasina negotiated agreements to address long-standing mutual concerns — Dhaka's on sharing the waters of the Teesta River and Delhi's on an overland transit to the Northeast. The two sides also negotiated a land boundary agreement that sorted out a range of vexing of issues that rose out of Bengal's partition in 1947.

When the stage was set in September 2011 for a transformation of India-Bangladesh relations, the chief minister of West Bengal, Mamata Banerjee, opposed the signing of the Teesta waters agreement and refused to join Singh in Dhaka at the very last moment. Instead of ignoring Banerjee's tantrums, Manmohan Singh held himself back. With Teesta off the table, so was the agreement on transit that would have brought immense benefit to the land-locked northeastern states of India. To make matters worse, the UPA is yet to table the land boundary agreement in Parliament.

In the last lap of his second term as prime minister, Singh must try and redeem his diplomatic investment of the last nine years to transform India's relations with Pakistan and Bangladesh and set a new course for the international relations of the post-Partition subcontinent. Delhi finds itself in a rare moment when it has friends at the helm in Islamabad and Dhaka. But the conditions and tasks for India's diplomacy are different in the east and west. In Pakistan, Nawaz Sharif will have a hard time overcoming the challenges of violent religious extremism; Sheikh Hasina, in contrast, is battling to preserve the idea of Bangladesh as a secular democracy.

In the west, Singh must necessarily wait for Nawaz Sharif to determine the pace at which he might be comfortable moving forward with India. In the east, the burden is entirely on Delhi to implement the historic agreements that it had negotiated with Dhaka. In Bangladesh, India's political credibility as an interlocutor is at stake. Manmohan Singh must sign the Teesta waters agreement with Hasina and the Congress party must recognize the national interest in an immediate ratification of the land boundary agreement with Bangladesh.

Moving forward with Hasina will indeed help Singh to reinforce Sharif's forward-looking agenda in Pakistan. India's Bangla initiative, after all, is not very different from what Delhi seeks with Islamabad. It is about creating a violence-free atmosphere for the resolution of political disputes, delineating boundaries, opening the region's frontiers for easier flow of goods and people, and sharing the region's valuable natural resources on an equitable basis.

This article originally appeared in the Indian Express.