When a U.S. air strike hit Sabratha in western Libya on Feb. 19, it reduced a building on the southern fringes of the city to rubble, killing dozens of militants and exposing a network of Islamic State cells operating just near the Tunisian border.
It also upended the lives of three young Tunisian women who were married to militants killed in the strike or its aftermath, and are now being held with their children in a Tripoli prison.
The women's accounts, given in a rare interview, shed light on how Islamic State was able to operate largely undisturbed in Sabratha as the cell's mainly Tunisian members plotted attacks back in their home country.
It is also an illustration of how the militant group may continue to find space amid Libya's turmoil even as it risks losing its stronghold of Sirte, another Libyan coastal city further to the east.
"We lived normally in the city, the neighbors knew us. We even went to the market and to the beauty salon," said Rahma al-Shekhawi, the 17-year–old wife of Noureddine Chouchane, a senior commander who officials say was killed in the February strike.
Some militants stayed in Sabratha as they prepared to move on to Sirte or to Syria, but most were planning operations in Tunisia, she said. "They were buying weapons under the eyes of our neighbors."
Local officials in Sabratha have long denied or played down Islamic State's presence in the city and it was not possible to confirm those statements.
But U.S. and Tunisian officials say Chouchane played an important role in preparing two major attacks on tourists last year, first at a museum in Tunis and then on a beach in the resort city of Sousse, after which he became a wanted figure.
But in Sabratha "the authorities never came looking for us even though everyone knew where we lived," she said. "It only changed after the strike."
Islamic State began expanding into Libya in late 2014, as fighters from the Libyan-dominated al-Battar battalion returned to the eastern city of Derna.
Over the following year, the group joined a military campaign in Benghazi, took full control of Sirte and carried out attacks in Tripoli, partly by merging with or recruiting local militants from the al Qaeda-linked group Ansar al Sharia.
Yet Islamic State failed to make the kind of rapid advances it achieved in the Middle East, struggling to raise revenue or win broad support in Libya's fractured society.
Membership tilted increasingly towards foreign fighters, with Tunisians the most numerous, residents and officials say.
In Sirte, the group set up a proto-state that followed the model established in Iraq and Syria, taxing residents, enforcing strict rules over dress and education and carrying out regular public punishments including executions. It has since lost parts of the city to pro-government forces.
But in Sabratha, where Tunisians were especially dominant, there was a looser structure, the prisoners said.
"There was no leader in Sabratha, everyone did their own thing," said Rahma al-Shekhawi, though she said the main focus was on expanding into Tunisia.
Rahma's sister Ghofran, 18, also married to an Islamic State member, said militants in Sabratha were divided into cells that were ready to defy the group's hierarchical structures.
"Each group had an emir who was working on his own strategy – some were making passports for Syria, some were working on Tunisia and others were working on Libya," she said.
"They always asked for instructions from the emir in Syria, who told them to obey the emir in Sirte, but they refused and they took decisions by themselves."
Only after February's air strike did local Libyan brigades, known as "thuwar" (revolutionaries) because of their role in the 2011 uprising that toppled veteran leader Muammar Gaddafi, take on the Islamic State militants in their midst.
With planes circling over the city, residents began searching for militants partly because they feared further strikes, said Wahida Bin Mukhtar al-Rabhi, the third Tunisian prisoner.
Rabhi and her 2-year-old son, and Ghofran with her 5-month-old daughter, fled south towards the desert with their husbands.
Rabhi said they went without food for a day as they tried to arrange help to get to the nearby town of Zawiya.
"The clashes started, and my son Bara was hit by bullets in his stomach and back. At that point my husband started shouting, 'there are women and children with us', but the thuwar didn't want to stop because they knew we were Islamic State and we might blow ourselves up."
Rabhi said she was searched and beaten by the local brigades and then handed over to Tripoli's Special Deterrence Force, who took her to identify her husband's body.
Her son was given treatment in a local hospital before they were both brought to the prison in the capital where dozens of other Islamic State suspects are also held.
Despite their uncertain future in Libya, the women say they don't want to return to Tunisia, where they suffered poverty and persecution for their Islamist beliefs.
"I want to be happy with my son, I want to get back to my life," said Rabhi. "I don't want my son to grow up in prison."