By Jibran Ahmed

PESHAWAR, Pakistan (Reuters) - A Pakistani army officer died on Tuesday after being shot by Afghan forces in a border clash, Pakistan's military said, a development likely to ratchet up tension between the neighbors who sources said were beefing up troop numbers on either side.

The main gates at Torkham, the most frequented official border crossing at the end of the Khyber Pass, stayed closed for a third day, leaving thousands stranded on either side.

Firing between Pakistani and Afghan forces first broke out on Sunday at the crossing, about 45 km (28 miles) west of Peshawar, over the construction of a new border post on the Pakistani side.

Pakistan's army chief attended funeral prayers on Tuesday for Major Jawad Ali Changezi, who was among nine Pakistani and six Afghan troops wounded in the fighting, security officials said.

Pakistani Prime Minister Nawaz Sharif's office and the Pakistani military's press wing also confirmed Changezi's death.

One Afghan soldier was killed, Afghan officials had said on Monday.

Relations between Pakistan and Afghanistan have been strained for months. Kabul says Pakistan harbors militants seeking to overthrow the Afghan government, among them the Haqqani network and the leadership of the Afghan Taliban.

Pakistan denies it supports militants and says it is building the gate to stop militants from crossing the border.

"This gate (is) considered essential to check and verify documentation of all border crossers," Asim Bajwa, chief spokesman for the Pakistani military, said on social media website Twitter on Monday.

Afghanistan summoned the Pakistani ambassador on Tuesday to register its protest at the violence, Afghanistan's foreign ministry said. Pakistan had similarly summoned the Afghan charge d'affaires in Islamabad on Monday, the Pakistani foreign office said.

The Pakistani army had moved heavy weaponry and additional troops to the Afghan border on Monday night, said Pakistani security officials, who asked not to be identified because they were not authorized to speak to the media.

On Monday, an Afghan border police commander also confirmed that reinforcements had been deployed to the Afghan side of the border.

In Afghanistan's eastern city of Jalalabad, more than a thousand mourners attended funeral prayers on Tuesday for the dead Afghan soldier. Angry protesters chanted "Death to Pakistan".

Hundreds of demonstrators burned Pakistani flags at another protest in the southern Afghan city of Lashkar Gah.

The Pakistan-Afghanistan border has long been porous and disputed. Afghanistan has blocked repeated attempts by Pakistan to build a fence on sections of the roughly 2,200-km (1,370-mile) -long frontier, rejecting the contours of the boundary.

(Writing and additional reporting by Asad Hashim in ISLAMABAD; Editing by Clarence Fernandez)