NEW YORK (AP) — The prime ministers of India and Pakistan met in New York Sunday, and in a step toward easing tension, agreed on the need to stop the recent spate of attacks in the disputed Kashmir region.

They also both accepted invitations to visit each other’s countries, although they didn’t set dates. But the nuclear rivals appeared at odds over whether an end to the Kashmir violence is necessary for stalled peace talks to restart, and India reiterated its demand that terrorist activity emanating from Pakistan must stop.

Indian Prime Minister Manmohan Singh and Pakistan’s Nawaz Sharif met for just over one hour at a hotel on the sidelines of the U.N. General Assembly. It was their first face-to-face meeting since Sharif was elected in May seeking to improve ties with Pakistan’s larger neighbor.

India and Pakistan have fought three wars, and relations have been strained since the 2008 Mumbai attacks blamed on Pakistan-based militants that killed 164 people in India’s commercial hub. This year, a renewed spate of violence has threatened a decade-long cease-fire on the Kashmir frontier.

Indian National Security Adviser Shivshankar Menon called Sunday’s meeting useful and constructive. He said that Singh and Sharif had tasked senior military officers to find a way to shore up the cease-fire along the so-called Line of Control.

“They were both agreed that the pre-conditions for forward movement in the relationship which they both desire is an improvement of the situation on the Line of Control where there have been repeated cease-fire violations,” Menon told reporters at a briefing.

“Our overall impression of the meeting was that it was useful because it provided an opportunity for high-level contact on issues that are troubling the relationship,” he said. “We will now see how both sides take it forward in the next few months.”

The top bureaucrat at Pakistan’s Foreign Ministry, Jalil Abbas Jilani, sounded more upbeat.

“It was an extremely positive meeting,” Jilani told a separate news conference. “The most significant impact was that the leaders expressed their commitment to have better relations between the two countries.”

Asked if Pakistan shared India’s view that an end to violence on the Line of Control was necessary for the peace process to advance, Jilani said Pakistan agreed that a “conducive atmosphere” was better for dialogue that produces results. But he said Sharif emphasized that “we should continue to talk.”

In comments Friday at the General Assembly, Sharif called it a chance for a “new beginning” in relations. Singh had downplayed expectations. Their talks came three days after twin attacks by suspected separatist rebels on Indian security forces killed 13 people in the Indian-held portion of Kashmir.

Singh raised the issue of terrorism emanating from Pakistan and reiterated the need for effective action against the perpetrators of the Mumbai attacks, Menon said.

Pakistan has put seven men on trial on charges they assisted in the Mumbai siege, but the trial has made little progress. Jilani said that now that a Pakistani judicial commission has visited India to interview witnesses, he was sure “this trial process would be speeded up.”

Leaders of India and Pakistan last met a year ago. Pakistan’s then-President Asif Ali Zardari met Singh during a visit to India in April 2012. He was the first Pakistani head of state to visit the country in seven years. The two also met in August 2012 on the sidelines of a summit in Iran.

That progress has been set back by the upsurge in violence in Kashmir, but the need for peace is intensifying. The impending U.S. military withdrawal from Afghanistan, where India and Pakistan have competing interests, adds new uncertainty to a region increasingly threatened by Islamic militancy.

Sharif, who has served before as Pakistan’s prime minister but was unseated in a 1999 coup, is contending with a surge in militant violence inside Pakistan itself. In the latest attack, a car bomb exploded on a crowded street in northwestern Pakistan on Sunday killing at least 40 people. Such attacks in the troubled city of Peshawar have claimed more than 140 lives since last Sunday.

Sharif wants to improve relations with India and boost trade to help Pakistan’s stricken economy. But he has an uphill task in persuading India that Pakistan and its security services are willing and able to stop attacks on India.

It’s also a politically sensitive time in India. Singh is expected to step down after elections there next spring, but the ruling Congress party will not want to be seen as soft on Pakistan when attacks in Kashmir are rising.