As a mother of young children, Fadumo Sheikh is used to rising early. Last Saturday she was due to prepare their breakfasts before they went to the local madrasa. But the day started earlier than ever when, at around 2am, she was woken by the sound of sporadic gunfire.

Within sight of Sheikh's home in Barawe, Somalia, crack American navy Seals had launched a lightning amphibious assault on the Islamist militant group al-Shabaab. Less an hour later they would be forced to retreat, their mission far from accomplished. Based on interviews with witnesses and members of al-Shabaab, as well as official statements and media reports, the Guardian can present the most comprehensive picture yet of the daring pre-dawn raid – and where it went wrong.

The Americans' target was an innocuous two-storey beachside house in Barawe, a fishing town of about 200,000 people that was a crucial slave trade port in the colonial era. In particular, they had planned the delicate operation of capturing, not killing, Abdulkadir Mohamed Abdulkadir, a Kenyan of Somali origin and senior commander of al-Shabaab who was linked to a number of terrorist plots.

The house, about 200 metres from the sea on the town's east side, is understood to be used by foreign extremists who have gone to Somalia to take up al-Shabaab's cause. The group's presence there was not news to Sheikh.

"I live in a house near the beach and I used to see the house every day. There were so many al-Shabaab fighters entering and coming out," she said. "I usually see them going back and forth but I had never thought that so important a person was living inside the house."

Early morning gunfire was unusual, Sheikh continued, except when al-Shabaab was conducting training exercises. "I raised my ears and I continued to hear the gunfire growing. I had no feeling or thought of such an attack from the Americans. I looked at my watch about 30 minutes later and heard one explosion and then, a few minutes later, another explosion occurred, like boom!"

What had been invisible to Sheikh and other residents of Barawe was the stealthy advance of navy Seal team six – the same unit that killed Osama bin Laden in Pakistan – in a speedboat towards the Somalian coastline before first light. The team consisted of about 20 Seals, according to leaked accounts, and their craft was flanked on the Indian Ocean by three small boats to provide back-up.

'They looked like three big cows'

The Seals swept ashore, but not everyone in Barawe was asleep in those chilly early morning hours. Abdurahman Yarow, a longtime resident of the town, recalled: "I was wrapping my turban on my neck and head to protect against the cold and heading to the mosque. When I had nearly entered it, I heard a sound behind me. I saw what looked like three big cows going towards the north of the mosque – it was dark so I could not identify well what they were.

"After only 10 minutes I heard the first guns – that is, when the gun battle occurred between al-Shabaab fighters in the house and the US forces. I now understand the big cows I saw in the night were the American special forces with their military bags on their backs going in the direction of the house they targeted."

The Seals took up positions inside the house's compound, according to a report by NBC, which continued: "Then a lone al-Shabaab fighter walked out into plain view, smoked a cigarette, and went back inside, one source familiar with the details of the raid said. The fighter played it cool, and gave no indication that he had spotted the Seals. But he came back out shooting, firing rounds from an AK-47 assault rifle."

guardian.co.uk

The element of surprise had been lost and al-Shabaab's fighters unleashed gunfire and grenades in a cacophony that rang out across the town, murdering sleep before dawn prayers. But the Americans continued on the offensive, according to an elder who did not wish to be named. "The attackers from the US divided into two groups," he said. "Group one, comprising six men, stormed the house and began shooting the people inside it, while group two, also of at least six men, were staying outside the house. The worst shooting took place inside where one al-Shabaab fighter was killed. Al-Shabaab had more fighters inside and they fought extremely hard against the Americans."

The elder continued: "The Americans tried to enter room by room into the house to start searching for the big fish but al-Shabaab got reinforcing fighters from other houses and then the situation deteriorated until the Americans retreated."

According to the NBC account, several Seals could see Abdulkadir through windows but he was heavily protected; according to al-Shabaab, he was not in the building. While Pentagon officials have been reluctant to provide a full narrative, they have said US forces retreated from the gun battle out of a concern for potential civilian casualties. Details leaked to the press suggest that the compound contained far more women and children than the Seals expected.

The commandos returned to their boat, grateful for having suffered no casualties, and finally there was calm. Sheikh recalled: "At 3am the call for prayer started, and all the gunfire stopped. A neighbour called me on the phone and said there is an attack against the mujahideen. When it became safe enough to see everything outside, I came out to look around. Outside the house which came under attack there were some fighters of al-Shabaab and some residents come to witness the incident.

Members of al-Shabaab, targeted in a failed US military raid on the Somali coast. Photograph: Feisal Omar/Reuters

"These al-Shabaab fighters were not talking to the people. Some of them were masked and you could not see their faces. I saw one dead man and he was loaded into a car for burial. They were saying 'the martyr', which is the only word that you can understand for an al-Shabaab member who's been killed."

The dead man was Abdulkadir's bodyguard, according to one source in the town. On Tuesday, the Somali defence minister, Abdihakim Haji Mohamud Fiqi, claimed two al-Shabaab members had been killed: "We have found that two senior commanders – one of them foreign – were killed in the attack despite the top target not being found." A UN official in Somalia also said two al-Shabaab figures had been killed: one Sudanese man and another of Somali and Swedish origin.

Sheikh continued: "There were more fighters and supporters of al-Shabaab coming to the house in the morning; they were vowing that they will kill anyone who is found working with the non-believers.

"On the beach, the residents were looking at items left by US forces. I saw a grey military bullet-proof jacket. There was also blood scattered on the ground. There were military boots on the ground which we suspect were those of the Americans."

Local backlash

In the aftermath of the US assault, al-Shabaab deployed more heavily armed fighters to patrol the streets of Barawe, while also posting men and anti-aircraft weapons on the beach. There was also a local backlash with a hunt for suspected informants who helped US intelligence locate the house. A man who frequently used the local internet café was arrested on Sunday and is still being held.

Al-Shabaab took control of Barawe in 2008 and it became a refuge for its senior figures after they lost control of the capital, Mogadishu, and other towns in 2011. These have included the leader Ahmed Godane, who has been described as Africa's most wanted man after the Westgate mall bombing in Nairobi; Omar Hammami, the so-called "jihadist rapper" from Alabama killed last month after falling out with Godane; and Abdulkadir himself.

A destroyed section of the Westgate mall in Nairobi, Kenya, an attack blamed on al-Shabaab. Photograph: AFP/Getty Images

Barawe is about 135 miles (218km) from Mogadishu. The nearest town where government and African Union forces have control is Shalanbood, only 68 miles (110km) away. To the east is the Ambaresa training camp for al-Shabaab's foreign fighters. Forced marriage is common in Barawe: when al-Shabaab commanders including foreign fighters come for their daughter, few parents can say no, even if the girl is underage.

The events of Saturday 5 October could boost al-Shabaab's confidence in its defences but also give it notice that the world's most powerful military is ready to bring the battle to its doorstep. Speaking at a mosque in Barawe on Monday night, al-Shabaab's military operations spokesman Sheikh Abiasis Abu Mus'ab said: "Western countries … have to bear in mind we know that we are your target, but we will not be caught off guard.

"We know you are sharpening your knives to cut our heads off. We know our enemies. We will not oversleep so you can attack us at once. We are always vigilant and your cowardly attacks will end in failure."

Daveed Gartenstein-Ross, who studies Somalia and al-Shabaab at the Foundation for the Defence of Democracies, described Barawe as "right now the strongest area of sanctuary" for the militant group. He said it was likely that al-Shabaab expected something like a foreign raid after it perpetrated the attack on Nairobi's Westgate mall.

Gartenstein-Ross said the probable immediate response by al-Shabaab would centre around strengthening its internal security and grip on Barawe, rather than launching another terror attack.

"The raid has made them very nervous," he added. "In Barawe it's already been reported that al-Shabaab has implemented curfews. There will be an uptick in operational security and they will certainly use the way they repulsed this attack by navy Seals as a propaganda piece."

US Secretary of Defense Chuck Hagel speaks to the press in Seoul. Photograph: Jacquelyn Martin/AP

But the US defence secretary, Chuck Hagel, said the operation in Somalia, along with a near-simultaneous one in Libya, demonstrated the "unparalleled precision, global reach and capabilities" of US counter-terrorism. "These operations in Libya and Somalia send a strong message to the world that the United States will spare no effort to hold terrorists accountable, no matter where they hide or how long they evade justice," Hagel said.

Pentagon spokesman George Little suggested that more special operations raids against al-Shabaab were yet to come. "Working in partnership with the government of the Federal Republic of Somalia, the United States military will continue to confront the threat posed by al-Shabaab," Little said in a statement on Monday. "The United States military has unmatched capabilities and could rely on any of them to disrupt terrorist networks and plots."