Islamic State fighters attacked an Afghan army post in the eastern border province of Nangarhar, near Pakistan, late on Thursday and killed at least 18 soldiers, a local official said.

Ahmad Ali Hazrat, head of the provincial council, said the attack took place in the Deh Bala district of Nangarhar and killed about 18 soldiers manning an outpost. A security official, who declined to be named, confirmed the account.

Attahullah Khoqyani, spokesman for Nangarhar's governor, said operations by Afghan troops backed by international forces, had killed about 25 Islamic State militants in two districts of the province in the past 24 hours.

Over the past two years, militants loyal to Islamic State have established a stronghold in eastern Afghanistan where they fight both Afghan security forces and the Taliban.

US and Afghan officials believe Islamic State has several hundred fighters but say the movement has been weakened by repeated drone strikes and special forces operations.

However the group has claimed a number of high profile attacks outside its eastern stronghold, notably against Shi'ite targets in the capital Kabul.