NOUAKCHOTT - In the middle of the desert, just inside the Mauritanian border, stands a tent. Inside is a VHF radio.
If an outsider passes by, the locals operate the device to warn the authorities.
The radio is a simple but effective link in a security system which, combined with grassroots work, has helped shield Mauritania from the Sahel's escalating jihadist peril.
To Mauritania's east, the death toll in Mali, Niger and Burkina Faso has been rising inexorably -- but this largely desert country of four million has not experienced an attack in almost nine years.
On Tuesday, Mauritania takes over the rotating presidency of the G5 Sahel, which coordinates the anti-jihadism fight of five countries in the region.
"Mauritania is a player which was able to overcome terrorism in 2011," said a French source. "We expect a lot from their presidency."
In 2005, Islamist groups expanded in Algeria, a neighbour to the north, and Mauritania began to come under attack.
In 2008, the former head of presidential security, General Mohamed Ould Abdel Aziz, took power by force and a year later was elected president.
Any qualms that Western countries had about his rise to power were put to one side.
Given the numbers of Mauritanians in emerging jihadist groups in northern Mali, the sense was "the jihadist threat could spread to Mauritania," said a French expert, speaking on condition of anonymity.
France and, to a lesser extent, the United States began sending instructors to support anti-terrorist units and strengthen Mauritanian intelligence.
The Mauritanian authorities, for their part, began investing in training and retaining soldiers.
Military spending increased, providing better and newer equipment, and soldiers' pay was paid directly into the bank rather than through officers, and soldiers were given social benefits.
Security, hearts and minds
Today, that programme to boost military morale and competence has borne fruit, as shown in the tight policing of the border -- a notorious weak point in the other Sahel countries.
Dozens of checkpoints have been installed on every major highway, and a huge buffer region bordering Mali has been classified a "military zone" barred to civilians.
"Any car driving there would be spotted and checked," said Hassane Kone, researcher at the Institute for Security Studies (ISS) think tank in Dakar.
The measure has enabled the authorities to nab armed gangs of cannabis traffickers, he said.
At the same time, Nouakchott launched a battle of the minds -- to deter vulnerable young people from joining the jihadists.
In 2010 a dialogue between leading Muslim scholars and around 70 jailed jihadists caused around 50 of the detainees to repent.
Some were sent to talk on television and in mosques, preaching to young people about the perils of jihad.
More than 500 imams were recruited and youngsters were offered vocational training after they left Islamic schools, giving them the chance of earning a living.
"We saw a sharp drop in jihadist recruitment at this time," said Kone.
"People are less accommodating to radical ideas, and the public is working more with the state."
In January, Mauritania's current president, Mohamed Ould Cheikh El Ghazouani, former chief of staff and ex-right-hand man of Aziz who stepped down last year, praised what he called this "spiritual opening."
"Anchoring the values of tolerance and acceptance of others (opens the way) to breaking down and destroying the religious basis of terrorist activity," he said.
Fill the void
Going hand in hand with these ideological and security missions was the task of spurring economic activity and providing local services.
This is one of the biggest challenges in other Sahel countries, where poverty and the vacuum of the state have given the jihadists golden opportunities.
Hence, out of the desert sprang a string of new towns -- Nbeiket Lahwach, Termessa, Bouratt and Chami.
"The point is to occupy the ground, to say to the nomadic populations which did not feel they had a place in the state: 'Your country takes care of you, protects you, cares for you, educates your children'," said Isselmou Ould Salihi, a Mauritanian journalist who specialises in jihadist issues.
The absence of attacks on Mauritanian soil -- as well as statements made in the United States -- has fuelled suggestions that a secret non-aggression pact exists between Nouakchott and the jihadists.
The US claimed to have found documents in 2011, in the Pakistani cache where former al-Qaeda leader Osama bin Laden was killed, that mentioned an attempt at rapprochement between the group and the Mauritanian government in 2010.
"Nothing has ever corroborated these rumours, they are false," says a source close to the government.
A western diplomat said, "there's no deal, although obviously there are historic and tribal links between the inhabitants of northern Mali and Mauritania."