At least 13 civilians were reported killed and scores injured when Kyrgyz and Tajik security forces exchanged fire across the border on Thursday and residents hurled rocks at each other in a clash over a water reservoir.
The frontier, dating to the Soviet era, is poorly demarcated and minor border disputes are frequent. The latest quarrel quickly escalated as border guards on both sides joined the fighting.
The two countries' foreign ministries said late on Thursday they had agreed a ceasefire and a troop pull-back after hours of talks. But a Kyrgyz government source said Bishkek feared it could permanently lose part of its territory after temporarily abandoning it.
One Kyrgyz border outpost was on fire after a Tajik mortar attack, while Kyrgyz forces retaliated by capturing a Tajik outpost, Kyrgyz border guards said. Hundreds of people have been evacuated from adjacent villages.
Clashes flared late on Wednesday along the frontier between Tajikistan's northern Sughd province and Kyrgyzstan's southern Batken province because of a dispute over a reservoir and pumping station, claimed by both sides, on the Isfara river.
Residents on both sides threw rocks at each other before clashes escalated and the sides began exchanging gunfire on Thursday, according to the security agencies of both countries.
Videos shared on social media showed people on the Kyrgyz side sitting in a trench with the sound of gunfire in the background. Another video showed several houses - purportedly those evacuated by Kyrgyz villagers - set ablaze. Reuters could not independently verify the footage.
The clashes broke out in the area which lies along the road connecting mainland Tajikistan and the Tajik exclave of Vorukh. The Kyrgyz source, who was not authorised to comment on the matter officially, said Bishkek feared it could be an attempted land grab by Dushanbe.
Kyrgyzstan's State National Security Committee accused the Tajik side of using mortars to shell the disputed water facility. Tajik authorities said the facility belonged to them and accused Kyrgyz forces of shooting at Tajik border guards.
Kyrgyzstan reported three civilians killed and 81 people including at least two soldiers wounded. Tajikistan reported three civilian deaths and 31 people wounded, without giving a breakdown of civilians and troops.
Tajikistan also accused Kyrgyz forces of shelling a bridge with mortars and rocket-propelled grenades.
Both countries host Russian military bases and maintain close relationships with Moscow. When the fighting broke out, the secretary of Kyrgyzstan's security council was in the Tajik capital Dushanbe to attend a meeting of a Russian-led security bloc of which Tajikistan and Kyrgyzstan are members.