They said 11 foreign fighters "of various nationalities" were detained when security troops from the country's top spy agency stormed three ISIS hideouts in the southern Khartoum suburb of Gabra.
Four foreign nationals hiding in one of the three properties escaped and were being pursued by security forces, the General Intelligence Directorate said.
It did not give the nationalities of the four men on the run or the 11 arrested by the troops. It also did not say what the terrorists were planning in Sudan or when they arrived.
Two of the five security men killed by the militants were officers, while the other three were enlisted men, the directorate said. A third officer was wounded.
All six casualties were shot at one of the three hideouts.
Clashes between security forces and militants are rare in Sudan, but the country is known to have homegrown groups who had a high degree of tolerance under the rule of former president Omar Al Bashir, who was ousted two years ago after nearly three decades in power.
Some of these groups are known to have links to militants across the region.
Sudan shares a desert border with Libya through which militants cross in both directions.
Eastern Libya is home to extremist groups. Sudan's border with Egypt, where ISIS militants have for years been battling security forces in the Sinai Peninsula, is heavily policed by the Egyptians.
Al Bashir has been convicted of corruption and is in prison facing charges connected to the shooting death of protesters against his rule in late 2018 and early 2019.
He is also charged with overthrowing a democratically elected government in 1989, thus breaching the constitution.
Under his rule, Sudan became a haven for militants, including the late Al Qaeda leader Osama bin Laden. His government was also linked to terrorist attacks in Africa and Yemen.
Also under Al Bashir, weapons and militants crossed the desert into Egypt and travelled on to Sinai and the Hamas-ruled Gaza Strip.
Sudan was removed last year from the US list of states sponsoring terrorism, a move made possible by Al Bashir’s unseating.