Al Qaeda-linked terrorist group al-Shabab has carried out a major raid on a military intelligence base in the Somali capital of Mogadishu.

The raid on the National Intelligence and Security Agency (NISA) base in Mogadishu started on Sunday morning with a suicide car bombing, as jihadists used a car bomb to get inside the compound. The armed militants engaged in heavy gunfire with security forces as they tried to enter the base, according to CNN.

"There is an attack against a base belonging to the security forces. The violent elements used a car bomb to get inside the compound. There was a heavy exchange of gunfire," Somali security official Adan Mohamed said, according to Agence France Presse.

The Somali government, however, said that the security forces thwarted the attack. Three militants and a Somali soldier were killed in the attack.

"The attack was successfully thwarted by our forces. None of our buildings nor bases were entered," NISA said in a statement, Voice of America reported.

The regional jihadist outfit al-Shabab later claimed responsibility for the attack. Al-Shabab military operations spokesman Sheikh Abdiasis Abu Musab claimed that the jihadists had taken over the building and killed many intelligent agents inside, Reuters reported.

"We captured the building and we are fighting inside it," Musab said. The terror group has also vowed to step up attacks on Somalia government bases in the capital city during the holy month of Ramadan.

Sunday's attack came a day after the jihadists stormed a police checkpoint on the outskirts of Mogadishu, killing 15 policemen. Al-Shabab, a designated terror organization by the U.S. and other countries, has been engaging in deadly clashes with Somalia's weak government since 2006.