MOGADISHU, Somalia — Militants in Mogadishu on Saturday carried out a multi-pronged, complex attack against the country’s parliament building involving a car bomb, suicide bomber and gunmen on foot, police said.

Frightened members of parliament blamed the military for failing to prevent the attack, but other politicians praised the army for limiting the attack’s damages.

At least seven people were killed, including six attackers and one soldier who tried to stop a suicide bomber from entering the building, said police Capt. Mohamed Hussein.

Other officials later indicated that more people died in the assault but gave no figures.

Many members of parliament were in the building as the attack unfolded. Two were wounded by gunfire, said legislator Mohamed Ali.

Parliamentarian Dahir Amin Jesow, who was inside parliament debating Somalia’s development bank when the attack began, said he and his fellow legislators evacuated out of the back of the building. No gunman entered parliament, he said.

The army failed to protect the legislators, one member of parliament said.

Al-Shabab, an al-Qaida-linked group, has carried out several such complex attacks in Mogadishu, including on the city’s main court complex and attempts against the presidential palace. The group was booted out of the capital in 2011 but still controls wide areas of southern Somalia.

The prime minister defended the security forces’ response, calling it swift.

Prime Minister Abdiweli Sheikh Ahmed said in a statement that the terrorists again showed they are “against all Somalis by killing our innocent brothers and sisters,” but he did not give a death toll and said the facts were still being established. Later, at a news conference, Ahmed said he had instructed the army to launch an immediate offensive against al-Shabab.

“Somalia’s army: You must move now to crush the enemy who merely cares about killing our people,” said an angered prime minister. “You must move now!”

In the aftermath of the attack, bodies could be seen lying near an entrance gate to the building.

Gunfire and two blasts rang out near the building long after the attack began and after police had confirmed six attackers’ deaths. Security forces shot and killed four men, Hussein said. The two other attackers who died were the driver of the car bomb and the bomber on foot.

The U.N. representative to Somalia, Nicholas Kay, said the parliament represents the people of Somalia and their hopes and aspirations for a peaceful country.

“Today’s attack is an attack against the people of Somalia for which there can be no justification,” said Kay, who commended the “prompt” response by Somali and African Union security forces.