PARIS/BENGHAZI, Libya (Reuters) - Three French soldiers were killed in a helicopter accident during an intelligence-gathering mission in Libya, President Francois Hollande said on Wednesday.

They are the first confirmed Western military casualties since it became known this year that special forces were operating on the ground in Libya.

"At this moment we are carrying out dangerous intelligence operations (in Libya)," Hollande said in a speech. "Three of our soldiers, who were involved in these operations, have been killed in a helicopter accident."

France took a leading role in the NATO air campaign that helped rebels overthrow autocratic leader Muammar Gaddafi in 2011. The country has since descended into chaos.

Western special forces from countries including France, Britain and the United States have sent small teams to western and eastern Libya.

The French have been working alongside forces loyal to eastern Libyan commander Khalifa Haftar, who launched a campaign against Islamists and other opponents in Benghazi more than two years ago but has rejected a Western-backed unity government in Tripoli.

A spokesman for Haftar's forces, Ahmed Masmari, said a helicopter carrying three Libyans - a pilot and two technicians - as well as the three French, had crashed on Sunday in the Magrun area about 75 km (47 miles) south of Benghazi.

Libyan officials had earlier said four people died in the crash, all of them Libyan. Masmari said the French had been gathering intelligence on fighters from Boko Haram, after some Malian militants loyal to the group had arrived in the area.

"It was probably a technical problem but the investigation has not finished yet," Masmari said.

However, the Benghazi Defence Brigades (BDB), a recently formed force of Islamists and other fighters, claimed after the helicopter crash that it had shot the aircraft down, killing four people, according to a statement posted on social media accounts close to the group.

The statement said that the helicopter was an M135 belonging to Haftar’s forces and that two foreigners and two Libyans were killed when the group shot it down with a rocket. Pictures purporting to show the wreckage of the helicopter were also posted.

The BDB includes fighters pushed out of Benghazi by Haftar’s forces. The group launched a new campaign last month south of the eastern city to regain lost ground. Fighting has been continuing, including in the area around Magrun.

Western powers have been backing Libya's U.N.-backed unity government, hoping it will seek foreign support to confront Islamic State militants, deal with migrant flows from Libya to Europe, and restore oil production to shore up the Libyan economy.

But Haftar has so far rejected the unity government, and hardliners loyal to him have prevented a rival government and the parliament, both based in the east, from formally endorsing the U.N.-backed body.

(Reporting by Emmanuel Jarry, John Irish in Paris and Aidan Lewis in Tunis and Ayman al-Warfalli in Benghazi, Writing by John Irish; Editing by Angus MacSwan)