* Pakistan's U.N. envoy blames Karzai for stoking tension
* Afghan U.N. envoy says "terrorist sanctuaries" in Pakistan
* Afghan troops took security command from NATO on Tuesday
Afghanistan and Pakistan traded accusations in the U.N. Security Council on Thursday over the whereabouts of Islamist extremists on their porous border as the United Nations described increased tensions between the neighbors as "unfortunate and dangerous."
Afghanistan's U.N. envoy, Zahir Tanin, told a council debate on the situation in Afghanistan that "terrorist sanctuaries continue to exist on Pakistan's soil and some elements continue to use terrorism as an instrument of foreign policy."
Pakistan's U.N. ambassador, Masood Khan, said "terrorists operate on both sides of the porous border" and that many attacks against Pakistan were planned on Afghan soil. He said aggressive policing and border surveillance were needed.
"We must not allow terrorists to manipulate and divide the people of Afghanistan and Pakistan," Khan told the council.
He told Reuters in an interview afterward that Tanin had been "ill-advised" to raise the border issues at the Security Council as Kabul and Islamabad were already talking through other channels. Khan blamed Afghan President Hamid Karzai for stoking tensions.
"When President Karzai meets our leadership he's most gracious, engaging, he's a statesman, but when he talks to the media he says things which inflame sentiment and that's most unhelpful and destabilizing," Khan said. "We have given very restrained responses."
Pakistan's role in the 12-year-old war in Afghanistan has been ambiguous - it is a U.S. ally but has a long history of supporting the Taliban in Afghanistan in a bid to counter the influence of its regional rival India.
Pakistan's military played a key role in convincing Afghan Taliban leaders to hold talks with the United States, U.S. and Pakistani officials said, although Afghan anger at fanfare over the opening of the Taliban's Qatar office this week has since delayed preliminary discussions.
"We were talking to multiple interlocutors behind the scenes and we have been asking them to participate in these talks, (telling them) that we think the war should come to an end," Khan told Reuters.
'SUCCEED OR FAIL TOGETHER'
U.S.-backed Afghan forces toppled the Taliban in late 2001 for refusing to hand over al Qaeda leader Osama bin Laden after the Sept. 11, 2001, attacks on the United States.
Pakistan helped the Taliban take power in Afghanistan in the 1990s and is facing a Taliban insurgency itself. The Pakistani Taliban, known as the Tehreek-e-Taliban, is a separate entity from the Afghan Taliban, though allied with them.
"Stability and sanctity of Pakistan-Afghanistan border is a shared responsibility. Robust deployment of Pakistani troops on our side is meant to interdict terrorists and criminals," Khan told the council. "This must be matched from the other side."
A spate of cross-border shelling incidents by the Pakistani military, who said they were targeting Taliban insurgents, has killed dozens of Afghan civilians in the past couple of years.
"We are very concerned with ongoing border shelling," Tanin told the council. "This constitutes a serious threat to Afghan sovereignty and the prospect of friendly relations between the two countries."
U.N. special envoy to Afghanistan, Jan Kubis, told the Security Council that the heightened tensions between Afghanistan and Pakistan were a serious concern, especially at this stage of Afghanistan's development.
"Such tensions are unfortunate and dangerous," he said.
The NATO command in Kabul on Tuesday handed over lead security responsibility to Afghan government forces across the country and most foreign troops are due to withdraw from the country by the end of 2014.
"It is for the two countries to address these concerns and problems and their underlying reasons, to build trust and to refrain from any step that could contribute to an escalation of tensions and inflamed public sentiments," Kubis said.
"They share common concerns and interests in fighting terrorism. They can succeed or fail together," he said.