MORONI, Comoros Islands, Oct. 5— Africa's most infamous soldier for hire and his armed band surrendered today to French troops who reversed his third coup in the Comoros Islands.

The takeover of the impoverished islands off Africa's east coast failed today after France, the former colonial power, sent troops to wrest power from the coup's leader, a Frenchman, Bob Denard.

Mr. Denard was the first to walk out today from the military barracks that he, two dozen mercenaries and 300 rebel Comorian soldiers had used as a base since deposing the Comorian President one week ago.

He was given a full body search by two French commandos wearing body armor and carrying submachine guns. The commandos, one firmly holding Mr. Denard's right arm, escorted the hobbling, 66-year-old mercenary to a waiting car.

Two of Mr. Denard's lieutenants followed him out of the barracks and were placed in separate cars. The three vehicles sped to an abandoned airfield near the central harbor in the capital, Moroni. From there Mr. Denard boarded a helicopter that flew north, presumably to the Hahaya airfield, 10 miles away, or to one of three French warships waiting offshore.

The rest of his men came out in groups of 10 and were put into vans, first the Comorian soldiers, then the rest of the foreign mercenaries.

The mercenaries, dressed in camouflage uniforms, were a combination of older, grizzled veterans, and younger men. All were heavily armed with automatic rifles and grenades on their belts.

They were were taken into custody by French troops who surrounded the barracks after landing on Wednesday.

Hours after French troops swarmed ashore, Mr. Denard freed President Said Mohammed Djohar and announced he was ready to abandon his latest coup attempt.

He had negotiated the terms of surrender with French officers until this morning, then called his mercenaries into a private meeting. They emerged tight-lipped to announce they were giving up.

"Today it's raining and today the Comorians are crying," Mr. Denard told reporters about an hour before his surrender.

Mr. Denard, gray-haired and limping after decades of soldiering, has staged several coups on this impoverished chain of islands between Mozambique and Madagascar since it gained independence from France in 1975. He virtually ruled the country through figurehead presidents from 1978 to 1989, when France negotiated his departure.

But Wednesday's intervention seemed to mark an end to French tolerance for the buccaneer who has claimed to have served French interests around Africa.

Mr. Denard had been living quietly in France since 1993, when he was given a five-year suspended sentence for trying to overthrow the Government of Benin in 1977. He remains under a death sentence there.

Since 1961, Mr. Denard has led uprisings in Zaire (when it was the Belgian Congo), Nigeria, Angola, Zimbabwe (when it was white-ruled Rhodesia), Iran and Yemen.

Map of the Comoros Islands.