By Mehreen Zahra-Malik

ISLAMABAD (Reuters) - Pakistan and Afghanistan failed to reach an agreement on border management in talks on Monday, officials said, after days of clashes at the border last week left four dead and thousands stranded.

Fighting broke out when Pakistan started building a barrier at the crossing to stop Islamist militants crossing over from Afghanistan.

That plan angered Afghanistan, which rejects the colonial-era Durand Line border drawn up in 1893 and objects to Pakistan building checkpoints along the disputed boundary.

The two countries agreed on a ceasefire on Thursday, and it was decided that an Afghan delegation led by deputy foreign minister Hekmat Khalil Karzai would visit Pakistan for talks on Monday.

Foreign Secretary Aizaz Ahmed Chaudhry on Monday informed the Afghan delegation that Pakistan planned to build four gates at different points on the crossing, a Pakistani foreign office official said.

"There was no final agreement but we have informed them (Afghanistan) of our position," the official said, requesting anonymity as he was not authorized to speak to the media.

"These gates are important for the safety and security of both Pakistan and Afghanistan."

A second Pakistani official said the foreign policy chiefs would hold further discussions at the Shanghai Cooperation Organization summit in Tashkent later this week.

A statement from the Afghan foreign ministry said the talks were held in an "amicable and friendly atmosphere" but said Karzai had raised what it called "various violations" by Pakistan, including setting up checkpoints in Afghan territory.

"Moreover, he strongly protested against Pakistan's ongoing unprovoked artillery shelling of Afghan villages," it said.

Thousands of vehicles normally pass through the crossing every week, making it a vital trade link between the countries.

On Monday, dozens of Pakistani traders protested outside the provincial parliament in Peshawar, demanding that Afghan refugees be deported.

Pakistan hosts some 2.5 million Afghans who have fled fighting in their home country.

A protest leader said the free movement of Afghans into Pakistan had destroyed peace in the country and needed to be checked.

Relations between the neighbors have been strained in recent months. Kabul accuses Pakistan of harboring militants seeking to topple the Afghan government and not doing enough to bring Afghan Taliban leaders, over which Pakistan holds some sway, to the negotiating table.

Pakistan denies supporting militants and says it is constructing the border gate to prevent anti-Pakistan militants crossing over from Afghanistan.

(Additional reporting by James Mackenzie in Kabul; Editing by Nick Macfie)