The attack bore all the hallmarks of the Islamist insurgents that have terrorised Mozambique’s far northern Cabo Delgado region for the past three years. Gunmen converged on a refugee-filled town. They waited, cutting off access by road. Then, at about 4pm on March 24, they opened fire.

More than a hundred insurgents laid waste to the coastal town of Palma, destroying civic buildings, robbing and setting fire to at least one bank and killing dozens of people, according to Mozambican officials, security consultants and a report by the African Union seen by the Financial Times. Thousands fled the violence.

On Sunday Mozambique’s army said that the town was safe again and “significant numbers” of insurgents were dead after days of battle.

But analysts said the attack on Palma was an inflection point in what has until now been a widely ignored African war. The town is about 15km from a multibillion-dollar natural gas investment and, after hundreds of staff had to be evacuated to safety, its future is under threat.

Even as President Filipe Nyusi insisted that the Palma attack “was not greater than others [in the past]”, French energy group Total suspended the $20bn development, which lies on the nearby Afungi peninsula and is Africa’s biggest private investment.

Map locating Cabo Delgado, Palma, Pemba and Maputo in Mozambique, plus Total gas installations on the Afungi peninsula

It has withdrawn all Total staff from the fortified site, according to a person briefed on the matter, effectively mothballing the project. It is not the first time that security concerns have interrupted work at Afungi; Total had previously stopped work for some time earlier this year. The company declined to comment.

Nyusi reiterated last week that Mozambique’s armed forces are up to the job and that “our appeal [to Mozambicans] is simple: do not lose focus, do not be disturbed”. But his government’s failure to contain the insurgency faces unprecedented scrutiny in what Alex Vines, Africa programme director at Chatham House, called “a morbid watershed moment in terms of international attention”.

Details of events inside Palma are murky. According to the AU report, the gunmen hunted down government officials. The insurgents shut down the local mobile phone network and survivors who witnessed the attack have only gradually trickled in to safe areas such as Pemba, the provincial capital which lies 400km from Palma.

The insurgency began with a local Islamist sect’s clash with the state, as represented by Nyusi’s ruling Frelimo, and the group has drawn upon local grievances in Mozambique’s poorest province, which lies roughly 2,700km north of the capital, Maputo. But it has also developed loose links to Isis, which claimed credit for the Palma attack five days after it began, saying that 55 people were killed.

Attacks such as Palma “are clear indicators that Isis continues to actively seek to spread its malign activity to new fronts”, said John Godfrey, the anti-Isis envoy for the US government, which officially regards the Cabo Delgado insurgents as “Isis-Mozambique” terrorists.

As the insurgents took control of the town, nearly 200 international contractors and local civil servants fled to a major hotel, the Amarula, according to the AU report and security contractors. Many were later flown by helicopter to Afungi by Dyck Advisory Group, a South African private contractor.

The Nyusi government has increasingly relied on private contractors to fight alongside its soldiers in recent years, although DAG’s contract has not been renewed and will end this month. DAG is investigating claims by Amnesty International that its staff committed war crimes in past operations in Cabo Delgado.

Other local people fled on foot or by sea. Zenaida Machado, a Human Rights Watch researcher, spoke to survivors who fled to the town’s beachfront as the sound of gunfire rang out behind them; many did not have time to look for their families. “Some of the people had to hide in the water, in the sea,” she said.

In the days since the attack, thousands of refugees have arrived in Afungi on foot, according to NGOs working in the area.

“Most are in shock and are dehydrated and hungry,” Sylvie Kaczmarczyk, a Médecins Sans Frontières emergency co-ordinator in Cabo Delgado, said last week. “We have cared for one baby with a bullet wound.”

Thousands more people are believed by aid agencies to still be hiding in the bush but observers said the government had not set out an evacuation plan. “In moments like this, the government must communicate,” Machado said.

Analysts said the events at Palma should not have come as a surprise. Insurgents had cut access to the town by road for weeks beforehand, forcing it to receive supplies by sea and air.

Patrick Pouyanné, Total chief executive, flew to Maputo earlier this year to personally warn Nyusi that the company wanted a 25km security cordon around Afungi. The president agreed to strengthen security, according to his government.

But the lack of military preparation for an assault on the town was “breathtakingly shocking and arguably verging on the negligent”, said Robert Besseling of Pangaea Risk, a business intelligence group.

The Mozambican army and police were defending Afungi at the time of the attack and later joined the battle to regain Palma.

Mozambican forces say they have now taken control but last week, when the army took journalists into Palma to show that the government was back in control, they came under fire from insurgents.

That leaves Total and Maputo contemplating the consequences of the attack.

Unlike its first suspension of operations, when essential workers remained, Total’s complete withdrawal of staff this time “suggests that Total expects the closure to be long term — probably more than a year”, said Joseph Hanlon, a Mozambique expert at the UK’s Open University.

US special forces have begun training Mozambican soldiers in counterinsurgency and similar Portuguese help is on the way, the Portuguese government has said. Analysts warn that it will be months at the earliest before these initiatives show results.

But, although the money and food stolen from Palma will replenish the insurgents’ resources, the sheer scale of Cabo Delgado’s population exodus could work against the insurgency, analysts said. “It has drained support and people to feed it,” Vines said.

Many of Palma’s former residents remain on the move, with little sign that the government can regain the initiative soon.

“Just imagine the people hiding in the bush,” Machado said. “There is no direction, there is no instruction on where to go.”