Somalia's new president has declared the country a war zone and instructed the army to prepare a new offensive against the al-Qaeda linked group al-Shabab.

The announcement by President Mohamed Abdullahi Mohamed on Thursday comes amid a worsening security situation as al-Shabab steps up deadly bombings in the capital since the country's new leader took office in February.

A car bomb blast on Wednesday at a Mogadishu restaurant killed at least seven people.

Mohamed wore a military uniform as he declared the new offensive and offered young fighters a chance to surrender.

"We tell the young, brainwashed al-Shabab fighters that they have a 60-days deadline to lay down the arms with which they use to kill their people and come to us," he said.

"We shall welcome them with open arms."

Al-Shabab has denounced the new president as an "apostate" and warned Somalis against supporting him.

The new leader also on Thursday replaced Somalia's military, intelligence and police chiefs.

The security restructure is seen as an attempt by Mohamed to consolidate power in the long-chaotic horn of Africa nation.

The changes also come roughly a week after the Trump administration approved greater US military authority to pursue al-Shabab in Somalia, including more aggressive air strikes as parts of southern Somalia will be considered areas of active hostilities.

READ MORE - Mohamed Abdullahi Mohamed: Help the Somali people

Al-Shabab has been pushed out of the capital and other major urban areas in Somalia by national and African Union multinational forces, but it continues to carry out deadly bombings and attacks in Mogadishu and elsewhere. Targets have included hotels, military checkpoints, and the presidential palace.

Somalia's security forces are under pressure to improve as they will assume responsibility for defending the country once the 22,000-strong AU force leaves by the end of 2020.

Al-Shabab is just one of the challenges facing the new government, which despite hundreds of millions of dollars of support from the international community still struggles to expand its authority beyond the capital and other selected areas.

Drought threatens about half of Somalia's population of 12 million, the United Nations has said, and hijackings of cargo ships off the country's coast in recent weeks have signaled a return to piracy on one of the world's most critical shipping routes.