As Somalia's government plans a new offensive against al-Shabab, the BBC's Mary Harper considers why the Islamist militants remain so brazen.

The storming by al-Shabab fighters of Villa Somalia, the seat of government in the capital, Mogadishu, last Friday did not take me altogether by surprise.

On a recent visit to this large, shabby, sprawling compound I was struck by the lackadaisical security.

True, I had to walk through a lot of checkpoints, but each one seemed more sleepy and chaotic than the next.

They prepared themselves to die like lionsAl-Shabab official

I was surprised the African Union and Somali government soldiers let my companion in: His name was not on the security list at the gate, and he was not carrying ID.

The day after the attack, in which at least 11 people were killed, I spoke by telephone to an al-Shabab official.

He sounded relaxed, assured and in a very good mood.

"Villa Somalia is meant to be the most protected part of Mogadishu, and Mogadishu is meant to be the most protected part of Somalia," he said.

"Yet we managed to strike the president's house. My advice to the apostate President Hassan Sheikh Mohamud is try to protect your house and your staff before trying to protect your country."

'Mogadishu music'

He then went on to describe in great detail how "our boys" prepared for the attack.

Image copyrightAFPImage caption
A car bomb rammed into a concrete barrier in front of the presidential palace on Friday

Image copyrightAFPImage caption
Security has been tightened across the city following the attack on Villa Somalia

Image copyrightAFPImage caption
The African Union now has more than 20,000 troops in Somalia

"They took time surveying the area, identifying the weak spots," he said.

"Then they made the car into a bomb by packing it with explosives.

"Then they prepared themselves to die like lions. After the vehicle blasted through the gates, our young foot soldiers went through five checkpoints to get to their target."

Since the beginning of this year, there has been a surge of attacks in Mogadishu. I was there for the first one, on New Year's Day, which occurred at the Jazeera Palace Hotel, near the heavily protected airport.

I was sitting with a group of friends when we heard an enormous explosion.

This was not the normal "Mogadishu music", the phrase locals use to describe the city's usual background noise of gunshots and the odd grenade.

A few minutes later, there was another huge blast.

This is a tactic increasingly used by al-Shabab - blow up a target with a car bomb, wait until the security services, ambulance drivers and members of the public come to help, then blow them up with a second bomb.

I was near the hotel, so I went up to the roof of my building. I saw fires from the explosions raging in the night, as volley after volley of gunfire ran out.

As the gunshots were so near to where I was, I was told to duck down and run back down from the roof in order to avoid stray bullets.

People trapped in the Jazeera Palace told us by phone that a minibus full of al-Shabab infantrymen had tried but failed to storm the building.

'Pay-as-you-go' militants

As well as the usual human and vehicle suicide bombs, improvised explosive devices, grenade attacks and targeted assassinations, al-Shabab has in 2014 started raining mortars down on several districts of Mogadishu during the night.

Civilian homes have been hit.

There have also been daytime clashes with the security forces in northern Mogadishu, which still has a significant al-Shabab presence despite the group's official withdrawal from the city in August 2011.

Image copyrightAFPImage caption
Mogadishu has been devastated by more than two decades of conflict

Image copyrightAFPImage caption
Civilians have borne the burnt of the years of war

Al-Shabab has left several other towns, including the lucrative port of Kismayo, but it continues to collect "taxes" in the areas it controls.

Some business people in Mogadishu have told me they still pay fees to the group.

As al-Shabab is such a secretive movement, it is difficult to say how many fighters it has. Recent estimates say it may have as many as 5,000, including the "pay-as-you-go" elements who are paid to carry out specific acts such as throwing grenades.

'Nice to die'

Al-Shabab At A Glance

"The Youth" in Arabic

Formed as a radical offshoot of the Union of Islamic Courts, which controlled Mogadishu, in 2006

Controls most of southern Somalia

Estimated to have 5,000 fighters

Announced merger with al-Qaeda in 2012

Back in Villa Somalia, I suggested to President Hassan Sheikh Mohamud that he was going backwards instead of forwards both politically and in terms of security.

There had been no major advances against al-Shabab since the seizure of the town of Jowhar in December 2012.

His normal cuddly smile disappeared from his face, and he looked decidedly cross.

"I do not agree with you on many of these issues. I believe the opposite is true," he said.

"We have established the basis for security institutions with new leadership and new legislation. But after 23 years of conflict, it's not rational to believe that miracles can happen."

To be honest, I found it odd that the main conversation amongst the people I met in Villa Somalia was about who the new Prime Minister, Abdiweli Sheikh Ahmed, would chose for his cabinet. With the continuing violence and the miserable conditions in which most Somalis live, why were they so obsessed with internal politics?

When I ask Somalis why al-Shabab has intensified its attacks in Mogadishu, some say it is a response to the planned new offensive by the Somali army and the African Union force, which is now 22,000 strong.

I put this to the al-Shabab official, who shrugged it off.

Image copyrightReutersImage caption
President Hassan Sheikh Mohamud, who was elected by MPs in 2012, is under pressure to end the conflict

"We are not at all worried about the new offensive, of which there is not yet a single sign," he said.

"We have been fighting since 2007. We are on the right path; we have honour; it is actually very nice to die if one dies for one's religion."

When the new offensive begins, in all likelihood al-Shabab will adopt its usual tactic of officially withdrawing from the remaining urban areas it controls.

Some of its fighters will remove their battledress and melt into the civilian population, others will move to the towns' outskirts.

But like mosquitoes in the night, al-Shabab fighters will continue to strike.

Like mosquitoes, they will sting where it hurts and will be difficult, if not impossible, to eliminate.