Soon after French forces landed in Mali, radical fighters swept into this dusty hamlet of mud houses and red dirt, and for five days last week their presence stood as a potent symbol of defiance.

The fighters went house to house, residents said, telling people not to fear. The militants insisted that they were targeting only “white guys and Malian soldiers,” though they later beat local Christians.

At makeshift checkpoints, they searched anyone they suspected of being a spy. They occupied houses, both to sleep and to hide weapons. They looted medicine from the hospital and stole chickens from residents.

In some cases, women were ordered to cover their faces, and men were told not to smoke. But the militants did not impose the harsh brand of Islamic law they have elsewhere in Mali, suggesting that they knew their takeover of Diabaly would be temporary.

It was: By Monday, French soldiers were on patrol here and the rebels had retreated. But a visit to Diabaly, the first by Western journalists since the militant takeover, revealed the challenges that await France and its allies as they try to beat back a violent Islamist movement that has split this country in two.

A look at the events leading up to the intervention in Mali.

Many of the obstacles have become predictable for any conventional army waging a counterinsurgency, but they are no less daunting for their familiarity. They suggest a long campaign ahead in a country that has traditionally been seen as a backwater but has suddenly been thrust into the center of an escalating war between Western forces and Africa’s Islamist extremists.

During their short stay, the militants thoroughly infiltrated Diabaly, residents said, turning this desert town of 24,000 into a sprawling human shield.

“They placed big guns on the roof to target airplanes,” said Suleiman Dambele, 56, a veterinarian, pointing in the direction of a nearby house in his neighborhood.

Residents said French airstrikes, while precise, landed uncomfortably close to the homes of civilians.

Barnabe Dakou, 63, and his family were sleeping when an airstrike destroyed two rebel pickup trucks in the street outside their home. Shrapnel sliced through the walls, injuring Dakou and his 40-year-old son, Francois. Outside, the trucks were burning, and the bodies of two militants lay near a door. The family huddled together the rest of the night. In the morning, they fled Diabaly.

“We took nothing with us,” Francois Dakou recalled. “We just ran.”

The extremist takeover of wide swaths of Mali has been nearly a year in the making. In March, Islamist fighters took advantage of a military coup and a rebellion by Tuareg separatists to sweep across the country’s northern half. They soon pushed out the secular separatists and implemented a harsh interpretation of Islamic law that included public amputations, stonings and whippings.

The Islamists are made up of three groups, including al-Qaeda in the Islamic Maghreb — the terror network’s West and North Africa wing — an offshoot of which took responsibility for last week’s hostage crisis in neighboring Algeria, which left at least 37 foreigners dead.

After the Islamists advanced southward on Jan. 10, seizing the town of Konna, France launched a surprise military intervention aimed at stopping them. Together with Mali’s government and a pan-African military force, the French say they are determined to drive Islamist fighters from the country.

But the militants were undeterred by France’s entry into the war. Despite a campaign of French airstrikes, they moved southward through Mali or Mauritania and entered Diabaly on Jan. 14.

Residents of Diabaly, which is only about 250 miles northeast of the nation’s capital, said Malian soldiers clashed with the militants but then retreated from the area. Although Malian military officials have said that French special forces were also in Diabaly fighting the militants, residents said they did not see any French soldiers until days later.

Residents said no civilians were killed in the airstrikes, despite their proximity to civilian areas. And even those who were injured appeared to accept the strikes as the only way to drive out the rebels, who had fled by Saturday morning.

“If we were not bombed, [the militants] would have killed all of us, and they would have stayed in Diabaly,” said Barnabe Dakou, who returned with his family on Saturday. The charred carcasses of the two destroyed trucks remained outside his house.

On Monday, French soldiers walked the town, securing areas where the rebels had stored weapons. Malian soldiers stood near their vehicles. Even after the rebel withdrawal Saturday, it had taken more than 48 hours to enter Diabaly because of concerns about snipers.

Destruction inflicted by the militants was most visible inside a church. A wooden cross was broken in two. The militants had fired bullets into the roof. Bible pages lay ripped on the concrete floor.

Raphael Dembele, a member of the town’s Christian minority, said the militants had beaten a group of Christians and told them they were no longer allowed to practice their religion. “They said: ‘This is the American way. We don’t need it,’ ” Dembele recalled.

Most of the Christians who fled last week have yet to return.

Muslims, too, are apprehensive. Residents said they didn’t want the soldiers, especially the French, to leave Diabaly. The militants, many believe, are hiding in a nearby forest.

“We are uneasy,” said Amadou Traore, 36, a butcher. “They can easily come back.”