Tajikistan's interior ministry said at least 15 assailants were killed and four more attackers detained. The clashes outside the capital Dushanbe broke out as the country prepared to celebrate Constitution Day.
Tajikistan said on Wednesday Daesh terrorists who crossed the border from Afghanistan were behind a clash with security forces that left at least 17 people dead.
"All (of them) are members of the so-called terrorist group 'Islamic State' [Daesh]", the border guard service said in a statement.
Tajik security forces killed 15 assailants when their armed gang attacked a checkpoint on the border with Uzbekistan earlier, officials said, adding that a soldier and a policeman also died in the clash.
"As a result of an operation conducted by law-enforcement forces, 15 members of an armed criminal group were neutralised and four more attackers detained," the country's interior ministry said.
The country's border guards said separately that five attackers had been detained.
The clashes outside the capital Dushanbe broke out as the country prepared to celebrate Constitution Day on Wednesday and the country's long-serving President Emomali Rakhmon was on a visit to Switzerland.
Rakhmon is expected to visit Paris later this week to meet with French President Emmanuel Macron as part of a rare European visit that will also take in the Czech Republic.
The armed gang of around 20 masked people attacked the Ishkobod border post located some 50 kilometres (30 miles) west of the Tajikistan capital after 2200 GMT (3 am local time), the interior ministry said.
It released pictures of several bodies lying next to burnt-out vehicles at the scene of the clash.
Tajikistan, a poor mountainous country of nine million people bordering Afghanistan, has been hit by conflicts since it gained independence after the collapse of the Soviet Union in 1991.
Tens of thousands of people were killed in Tajikistan during a five-year civil war in the 1990s when rebel groups rose up against the government.
The authorities in the majority-Muslim country have said that more than 1,000 Tajiks joined militants in Syria and Iraq in recent years.
In May, at least 32 people were killed in a prison riot in Tajikistan, including 19 Daesh members and several guards.
The prison in Vakhdat, 17 kilometres (11 miles) east of the capital Dushanbe, holds 1,500 inmates.
In July 2018, an attack on foreign cycling tourists left four dead and two injured.
The assault was widely attributed to the Daesh terrorist group.