An Afghan official says the government is investigating links between universities and extremist groups following the arrest of 27 students in connection with a pro-Islamic State demonstration.

Javed Faisal, spokesman for Afghanistan's chief executive Abdullah Abdullah, said on Wednesday the authorities want to ensure universities do not become hotbeds of extremist activity.

The 27 students were arrested during a raid this week at Nangarhar University in the eastern city of Jalalabad.

The national intelligence agency says banners and other extremist paraphernalia were seized during the raid, which came after a student rally on the campus last week in support of the IS.

IS affiliates have built a presence in eastern Nangarhar province this year, fighting government forces and Taliban. They are believed to control some districts near the Pakistan border.