The military later said they had defeated the insurgents.
"We were awakened at 6:00 am by continuous loud explosions and the sound of shooting," said a resident of Abu Zabad, in North Kordofan state.
He asked not to be named for security reasons.
"Armed men in Land Cruisers drove into the town and targeted a SAF compound and the police station," he said, referring to the Sudan Armed Forces.
The town, in an agricultural region, is home to a small military facility.
He said he had seen the rebels arrive earlier at the local market, firing their weapons in the air.
They appeared exhausted, thirsty and in need of fuel, he said.
Their aim was "to loot fuel and food materials from the market", armed forces spokesman Sawarmi Khaled Saad said in a statement to the official SUNA news agency.
The Justice and Equality Movement (JEM) earlier today said it "took control" of the small community which is a few kilometres from South Kordofan state, where rebels have been fighting for two years.
Saad later said the military had repulsed a JEM attack on Abu Zabad and killed the rebel commander.
Abu Zabad, about 150 kilometres southwest of the North Kordofan capital El Obeid, is alongside the country's main east-west railway line.
It is also about 60 kilometres from Dilling town in South Kordofan, where JEM rebels and fighters from the Sudan People's Liberation Army-North last Tuesday claimed their first major attack of the dry season.
They said they ambushed a military convoy near Dilling, leaving "many dead bodies".
"The road between Dilling and El Obeid is open and movement is normal," he said, quoted by the Sudanese Media Centre which is close to the security apparatus.
