(CNN) -Islamist rebels attacked a prison in Somalia on Sunday and were fought off by security guards, who killed seven of the rebels, Somali Security Ministry spokesman Mohamed Yusuf told CNN.
Al-Shabaab fighters used a car bomb and guns in the assault on the National Intelligence and Security Agency prison in Mogadishu, killing three security guards and two civilian in the "foiled attack," Yusuf said. He said more than 15 others were injured.
"The attackers exchanged heavy gunfire with prison guards after detonating a car bomb at the main gate," said eyewitness Farah Mohamed. "A plume of dark smoke could be seen rising from the attacked complex," he said.
The militants who stormed the jail were wearing government military uniforms; some were riding in a car and others were on foot, said police Officer Abdifarah Ali.
He said the attackers tried to free their fellow Al-Shaabab members held at the prison, who were sentenced to death by a Somali military court tribunal.
"We were behind today's raid on NISA prison in Mogadishu," Al-Shabaab spokesman Sheikh Abdiaziz Abu Musab said on pro-militant radio station Al-Andalus. "Our Mujahideen forces stormed the complex and then sprayed the prison guards with bullets and bombs," he said.
The government praised the security forces, saying it shows that Somalia has improved security.
"These terrorists groups are against the security improvements we are currently experiencing here in Mogadishu," Information Minister H.E. Mustafa Duhulow said in a statement. "We say to them that these foiled attacks strengthen our forces and prove their bravery to the people of Somalia," he said.
The NISA prison is underground and is close to the Somali presidential palace in Mogadishu. Hundreds of inmates, mostly Al-Shabaab members, are being held there.
Al-Shabaab is an al Qaeda-linked militant group seeking to turn Somalia into a fundamentalist Islamic state, according to the Council on Foreign Relations.
The group claimed responsibility for the deadly attack at a Kenyan mall last year and is believed to be responsible for attacks in Somalia that have killed international aid workers, journalists, civilian leaders and African Union peacekeepers.