KABUL, Sept 2 (Reuters) - Taliban forces and fighters loyal to local leader Ahmad Massoud battled in Afghanistan's Panjshir Valley on Thursday, more than two weeks after the Islamist militia seized power, as Taliban leaders in the capital, Kabul, worked to form a government.

Panjshir is the last province resisting rule by the Taliban, who retook control of the country as U.S. and foreign troops withdrew after 20 years of conflict following the Sept. 11, 2001, attacks on the United States.

Each side said it had inflicted heavy casualties.

"We started operations after negotiation with the local armed group failed," Taliban spokesman Zabihullah Mujahid said.

Taliban fighters had entered Panjshir and taken control of some territory, he said. "They (the enemy) suffered heavy losses."

A spokesman for the National Resistance Front of Afghanistan (NRFA) rebel grouping said it had full control of all passes and entrances and had driven back efforts to take Shotul district.

"The enemy made multiple attempts to enter Shotul from Jabul-Saraj, and failed each time," he said, referring to a town in neighbouring Parwan province.

Since the Taliban swept into Kabul on Aug. 15, several thousand fighters from local militias and remnants of the government's armed forces have massed in Panjshir under the leadership of Massoud, son of a former Mujahideen commander.

They have been holding out in the steep valley where attacks from outside are difficult.

Efforts to negotiate a settlement appear to have broken down, with each side blaming the other for the failure.

Mujahid said the announcement of a new government was a few days away, while Taliban official Ahmadullah Muttaqi said a ceremony was being organised at the presidential palace.