South Asian heads of state attending their first summit in three years reached a deal on energy sharing Thursday, but failed on two other economic agreements during a retreat where Indian and Pakistan leaders shook hands.

On the last day of the two-day summit, the leaders flew to a mountain resort near Nepal's capital and agreed on electricity sharing among the eight nations through a common grid.

During the retreat, Indian Prime Minister Narendra Modi and his Pakistani counterpart, Nawaz Sharif, shook hands and talked in a group, but did have one-on-one dialogue, according to Nepalese officials.

Indian officials have already said exchanging courtesies among the leaders did not mean talks between the two South Asian rivals.

"If they interact, exchange courtesies and exchange a few words, that does not translate as dialogue," Indian External Affairs Ministry spokesman Syed Akbaruddin said earlier.

The leaders of Afghanistan, Bangladesh, Bhutan, India, Maldives, Nepal, Pakistan and Sri Lanka boarded helicopters from Katmandu to the retreat at Dhulikhel, 30 kilometers (19 miles) away. The area is a popular viewing spot of the Himalayan mountains.

The trip Thursday gave them a final chance to reach agreements that were expected to be signed during the meeting.

Officials indicated that Pakistan had made last-minute objections to energy sharing, roads and railways connectivity agreements because of incomplete internal procedures, but at the end, the energy deal was clinched.

The South Asian Association for Regional Cooperation summit, the first since 2011, is meant as a forum to discuss regional issues, but is usually dominated by the rivalry between Pakistan and India. It is supposed to be held annually, but is often shelved due to member nations disagreeing on meeting dates.