The armed men first attacked a Tajikistan border post at dawn on Friday, killing two Tajik soldiers and reportedly stealing several guns.
The group then fled into Kyrgyzstan, killing two more soldiers and seizing more weapons. There were reports of civilian casualties in both countries but these could not be confirmed.
Miroslav Niyazov, secretary of the Kyrgyz security council, later said that special forces had found the gang, which numbered between six and ten men, and had surrounded them.
The attacks took place in the Tajik and Kyrgyz parts of the Ferghana Valley, which the two countries share with Uzbekistan.
The motive for the attacks remains unclear, although the mountainous border region is a transit route for drug smugglers from Afghanistan.
The area is also known as a centre for Muslim fighters.