The French president, François Hollande, flew into the Central African Republic on Tuesday evening following an announcement earlier confirming the deaths of two French soldiers in clashes with militia forces they had ordered to disarm – the first losses in the French campaign in its former colony.

On his arrival in the capital, Bangui, the French president described the mission as "necessary but dangerous".

Hollande had flown directly from Nelson Mandela's memorial service in South Africa to CAR, where around 1,600 French troops have been deployed, alongside 2,500 African Union soldiers, to try to stop the bloodshed between religious factions.

The two soldiers, from the 8th regiment of marine infantry parachutists, based at Castres in southern France, had been part of a team inspecting an area east of Bangui's airport close to midnight on Monday before a disarmament operation, according to a French military spokesman, Colonel Gilles Jaron, speaking in Paris.

Gunmen fired on the French patrol, which returned fire, he said. Two Frenchmen were wounded and taken to hospital, where they died. It was unclear whether anyone else died in the clash.

In a statement, Hollande's office praised their bravery and said the men, who died five days into Operation Sangaris, had "lost their lives to save many others". The Elysée palace said: "The president of the republic has learned with profound sadness the deaths in combat of the two soldiers … the head of state expresses his profound respect for the sacrifice of these two soldiers and renews his full confidence in the French forces deployed, alongside the African forces, to re-establish security in the Central African Republic, to protect the population, and to guarantee access to humanitarian aid."

Tensions flared up again on Tuesday in the CAR as a mob of young men set fire to a mosque in the Fou area of Bangui. Smoke billowed from vehicles nearby, and men used pickaxes and whatever tools they could find to try to tear down the walls of the mosque.

French troops were sent to the country having been given the go-ahead by the UN security council on Thursday after more than 450 people, many of them women and children, were killed in a series of massacres.

They began disarming former rebels and militias who had carried out a series of bloody reprisals over recent weeks and sown terror among the population of the CAR, especially in the capital.

Rebels known as the Séléka, a mostly Muslim coalition, overthrew the government of the majority Christian nation nine months ago.

The Séléka and other armed groups had been given an ultimatum by the French to return to their bases and hand over their weapons.

Jaron told journalists that most armed groups had been cleared from Bangui's streets. The military spokesman said: "There was no fighting in Bangui. At no moment did these groups try to engage in combat against us."

He said French troops had come up against "furtive firing" and had briefly fired back, but he said these exchanges had now stopped.