An assailant has killed two Sudanese soldiers before being shot dead himself as he tried to enter the building where President Omar al-Bashir has his offices.
The attacker refused to stop at the presidential palace's western gate before seizing a gun from one of the guards, killing two of them and being shot dead himself, presidential press secretary Emad Sidahmed told AFP.
Bashir and his ministers were not in the palace at the time of Saturday's attack, Sidahmed said.
Army spokesman Colonel Al-Sawarmy Khaled Saad said the attacker, who he described as "insane", arrived at the gate with a sword, which he used to stab one guard.
The man then "took his weapon and shot the guard and killed another one" before other soldiers opened fire on him, Saad said.
Saad named the attacker as Salah Kafi Quwa, and said he was originally from the town of Kadugli in South Kordofan state, where insurgents are battling the Khartoum government.
The situation outside the palace was quiet on Saturday afternoon after the incident, and police had shut of one of the streets around the palace, an AFP correspondent said.
Last month Bashir's National Congress Party said the 70-year-old, who is wanted by the International Criminal Court for alleged war crimes in Darfur, would stand for re-election in 2015.