MOGADISHU, Somalia—French commandoes on Saturday attacked a base of Islamist militants in Somalia in a hostage rescue attempt, a Somali intelligence official said. Residents of the town said they heard explosions and gunfire.

The attack occurred in the town of Bulomarer, and come on the heels of French military intervention in Mali, another African country. The intelligence official, who insisted on anonymity because he was not allowed to discuss the case with the press, said the French commandos were trying to rescue a kidnapped military advisor who they were tipped off was being held there. A French security adviser was kidnapped by the militant Islamist group al-Shabab in Mogadishu, the capital, in 2009.

The intelligence official said the raid caused casualties but that he had no information on the hostage.

"We are aware of the deaths of several al-Shabab fighters during the operation," he said. "Helicopters dropped off soldiers to rescue the man. We don't have confirmations that the man has been rescued."

With France having acted Friday to help Mali against al-Qaida-linked militants who hold more than half of that country and are encroaching further on government-held territory, the raid in Somalia could have been aimed at preventing al-Shabab fighters from harming the French hostage in reprisal. The attack was swift and loud, local residents said.

"We heard a series of explosions followed by gunfire just seconds after a helicopter flew over the town," Mohamed Ali, a resident of Bulomarer, told The Associated Press by phone. "We don't know exactly what happened but the place was an al-Shabab base and checkpoint."