DIFFA, Niger This West African desert town hardly seems like the front line of an emerging struggle against terrorism. The market is bustling. Young men listen to French rap music blaring from boomboxes. Boys play soccer on unpaved roads.

Yet the nearby border checkpoint with Nigeria, where hundreds of people once crossed back and forth daily, is now closed. Soldiers patrol the streets day and night. And a U.S. Special Forces captain and his comrades, who fought in Iraq and Afghanistan, are here, training Niger’s ragged army.

“We are in the center of some big problems,” said Kolo Ligari Katiella, a U.N. regional security official and former police officer here.

In recent years, Islamist radicals have staged suicide attacks and kidnapped Westerners in North and West Africa. But in the aftermath of the Arab Spring revolts, the fight against militant Islam in this moderate swath of Africa has gained fresh urgency. The swift takeover of northern Mali by al-Qaeda-linked militants, aided by weapons and fighters from Libya, has raised alarm that an explosive cocktail of rebellion, terrorism and religious extremism could spill across borders.

Such concerns are increasingly visible in Diffa and other towns nestled along Niger’s long border with Mali and northern Nigeria, where Boko Haram, another Islamist militia with suspected links to al-Qaeda, has intensified attacks this year. In such places, local officials and U.N. workers say, fundamentalist Islam is slowly replacing Sufism, a more open, mystical brand of the faith that has been practiced here for centuries.

Boko Haram is trying to spread its hard-line ideology and violent aspirations in these border towns, and its fighters are using Niger as a gateway to join up with the Islamists in northern Mali, U.N. security experts and local officials say. Diffa, in particular, is about 100 miles from Boko Haram’s main base in Nigeria and is known as a hideout for the militia’s leaders and other members escaping authorities in Nigeria.

“We have al-Qaeda north of us and Boko Haram to the south,” Katiella said. “The population lives day by day in fear because they face plenty of threats.”

In a post-Osama bin Laden world, the United States and its allies are increasingly concerned that ungoverned patches of Africa could become new havens for global jihadists. While terrorist attacks declined globally last year compared to 2010, including in Iraq and Afghanistan, they increased 11.5 percent in Africa, according to the State Department’s most recent terrorism report.

The instability is affecting a region whose economic importance to the United States and other Western countries is growing. Nigeria now supplies more oil to the United States than most Middle East countries. Niger is one of the world’s biggest producers of uranium, used in weapons and to fuel nuclear plants, and its mines are located in an area where al-Qaeda militants are active. The European Union also plans to send experts to train Niger’s security forces to combat al-Qaeda.

“This region’s stability is very important to all of us,” said Special Forces Capt. Danny, who did not provide his last name as required by protocol.

The fall of Moammar Gaddafi’s regime in Libya sent thousands of Tuareg tribesmen who fought for him, along with massive arsenals of weapons, into northern Mali, their ancestral home. There, they joined other Tuareg insurgents and al-Qaeda-linked extremists and ousted the government from the northern part of the country. Within weeks, the Islamists had taken control of a territory the size of Texas.

Today, the Islamists in Mali have imposed strict Islamic laws reminiscent of the Taliban in Afghanistan, banning television and soccer and ordering women to wear full-length robes. Their harsh justice, enforced by whippings, beatings and executions, has forced tens of thousands of Malians to flee to neighboring countries, including Niger, whose population is already suffering from a severe hunger crisis.

Equally worrisome for Niger is that its own Tuareg separatists have revolted in the past and that al-Qaeda militants are active, kidnapping Westerners. Both groups have potentially easy access to Gaddafi’s weapons, making Niger even more vulnerable to terrorism.

Meanwhile, Boko Haram’s attacks against churches, banks and government institutions in northern Nigeria are triggering economic turmoil in southern Niger. The sudden return of tens of thousands of migrant workers after Libya’s collapse is also adding to the strains on Niger’s economy, potentially creating a new crop of impoverished recruits for Africa’s Islamists.

A recent two-week-long journey to the Mali border and along southern Niger’s frontier with Nigeria revealed how much this landlocked nation is struggling with the threat of militant Islam. “We are under pressure from all sides,” said Niger’s justice minister, Marou Amadou.

Free flow of militants

For the past two months, Yusuga Maiga has watched with concern as the refugee camps near Mali’s border have swollen. As the governor of Tillaberie, one of the regions most affected by the hunger crisis, he’s worried that the new arrivals will tussle with his poor constituents for food and other resources.

But Maiga, who is also a military general, is most concerned about an infiltration of Ansar Dine, whose name in Arabic means “defenders of faith.” The Islamist group, which rules northern Mali, is aligned with al-Qaeda in the Islamic Maghreb, or AQIM, the terror network’s North and West Africa affiliate. Fighters from both groups, along with other smaller Islamist factions, are across the border, and Maiga has dispatched his soldiers to patrol the area day and night.

Since March, when northern Mali was seized, more than $80 million of the national budget has been diverted to defense and security needs, senior government officials said. The funds, they said, were previously allocated for education, justice, health and social development.

Even so, Maiga conceded that it is difficult to prevent the flow of fighters and weapons. The 510-mile-long border is, in most places, a mere imaginary line in the desert sand, easy to cross unnoticed.

“Any problems affecting Mali will affect Niger,” Maiga said. “We are the same ethnic group. We dress the same. We use the same turbans. We drink the same tea. It’s very difficult to identify who is from Ansar Dine.”

The case is the same along Niger’s 930-mile-long border with Nigeria, where several tribes also live on both sides of the frontier.

Still, the Nigerien government has had some success in thwarting Boko Haram’s aspirations. Since March, at least 13 loyalists and fighters have been arrested on the way to northern Mali, apparently to support the rebellion or receive training from AQIM, said Justice Minister Amadou. In January, a United Nations Security Council report stated that seven Boko Haram loyalists passing through Niger were arrested with “names and contact details” of AQIM members.

In Diffa, authorities arrested several dozen suspected Boko Haram members in February and seized homemade explosives and grenades, said government and U.N. security officials. The group, authorities said, was trying to set up a cell in the area.

U.S. and U.N. officials are worried that Gaddafi’s arsenal, including rocket-propelled grenades, light antiaircraft artillery and shoulder-fired missiles, could end up in the hands of Boko Haram and AQIM.

While anecdotal evidence suggests links between Boko Haram, AQIM and the Islamists in Mali, security experts say it remains unclear whether any relationship has been formalized.

In Niger, there are no such doubts.

“They are all part of the same network,” Maiga said.

Fear among Christians

Hundreds of miles away, in the town of Zinder, fear grips Pastor Prince Uzoigwe. Last Christmas, Boko Haram threatened to target churches across southern Niger. The local police dispatched 20 officers to protect his small chapel.

In recent weeks, unknown people have thrown rocks into the church compound and destroyed its security lights. Others have hurled insults from outside the gate. In one incident, his wife was pelted with stones as she left the church. Uzoigwe blames the attacks on Boko Haram and its sympathizers here.

“They are planning day by day to attack us,” Uzoigwe said. “They need just one day to remove Christians in Niger.”

“Zinder is the center of Islam in Niger,” he added a few moments later. “They hate Christians. They hate us.”

U.N. and local officials say Islamic fundamentalism is creeping across southern Niger. There are more mosques that preach sharia law and radical brands of Islam. More children now study at Koranic schools. More women wear veils or floor-length garments; more men have beards.

“Diffa is the place where the insurgents go and rest,” said Guido Cornale, the chief of the United Nations Children’s Fund in Niger. “Zinder is where you have the religious side of Boko Haram gaining ground.”

Some locals openly expressed their support for Boko Haram.

“If I was attacked by Boko Haram, it’s like being attacked by God,” said Al Haj Abdu Maharaju, a trader in Maradi who makes frequent trips to northern Nigeria.

“It’s God wish. I have no problem with that.”

Violence tempts the idle

In the town of Goure, tens of thousands of men who once worked in Libya are now languishing, unemployed. They once supported dozens of relatives with their remittances; now most of those relatives are also unemployed and searching for food. Local officials blame the returnees for a sharp increase in robberies and other attacks.

They worry that some of them will join the Islamists in Nigeria or Mali. “All is possible,” said Alassan Mamam, an aide to Goure’s mayor. “They have nothing to do. They don’t possess anything, and they are hungry and poor.”

Adding to their woes are the Boko Haram attacks. Most southerners depend on northern Nigeria for goods, but the lawlessness there, border closings and intensified security searches have driven up prices of staple foods such as millet by 60 percent. “When I go to Nigeria these days, I am taking a huge risk,” said Alaji Rabi Ali, a trader in Maradi. “So I have to raise my prices.”

This year, Boko Haram sent several threatening letters to Muslim imams who preached against the militia’s ideology, said U.N. security officials. As in other areas, Boko Haram has its sympathizers here. Some families are refusing to vaccinate children because they view it as a Western conspiracy or have stopped sending girls to schools. Men from Diffa have traveled into Nigeria to fight alongside Boko Haram.

Against this backdrop, Capt. Danny and his Special Forces team are training Nigerien soldiers to better patrol their borders and to better engage with the local population. But senior government officials believe they deserve more international sympathy and support for their struggle against the Islamists. They say a military intervention in Mali is the best way to erase the threat, as well as send a strong warning to Boko Haram.

“We have controlled the situation up till now, but I’m not sure how long we can keep it under control,” said Amadou, the justice minister. “When we cry, we need to be heard by the world.”