Suspected Islamist fighters attacked a town in western Mali just a week after Sidi Brahim Ould Sidati of the Coordination of Movements for Azawad signed a peace agreement in Bamako, Mali, June 20, 2015 Reuters

BAMAKO (Reuters) - Suspected Islamist fighters attacked a town in western Mali near the border with neighboring Mauritania before dawn on Saturday, leaving 12 people dead, including three soldiers and nine attackers, the defense ministry said.

The ministry's statement did not identify the assailants, but a senior army officer said military intelligence and initial witness accounts indicated the attackers were Islamist fighters mainly from the Peuhl ethnic group.

The raid took place just a week after a Tuareg-led northern rebel alliance signed a peace deal with the government aimed at ending their uprising and allowing the authorities to focus on fighting Islamist militants.

Gunfire erupted at around 5 a.m. (0500 GMT) in the town of Nara, around 30 km (19 miles) south of border with Mauritania.

A resident of Nara said gunfire could be heard several hours after the clashes began and town residents locked themselves inside their homes. Heavy fighting flared again around midday before the army regained full control in the early afternoon.

The statement said the gunmen attacked a military camp in Nara, though an army spokesman said they also targeted a bank.

"They then occupied the prefecture. Their methods indicate an infiltration in advance and a well planned operation," said Souleymane Dembélé, the army's director of information.

Government soldiers carried out house-to-house clean-up operations throughout the afternoon.

A second resident said he saw bodies lying in the streets in the wake of the fighting.

"I saw four bodies of the people who came to attack and one of a Malian soldier," said resident Issa Traoré. "The last few days we've informed the military authorities about the presence of strange men in the town."

A senior army officer, who asked not to be named, said the attackers were mainly Peuhls infiltrated by fighters believed to be linked to al Qaeda in the Islamic Maghreb.

"For two days intelligence has indicated the presence of small groups of Islamists travelling in several pick-ups," he said.

A relatively new Peuhl armed group called the Massina Liberation Front, which is suspected to have clashed with government troops in the central Mopti region earlier this month, has been blamed for a growing number of attacks.

A French-led military campaign in early 2013 liberated northern Mali from al Qaeda-linked Islamist rebels, who seized control of the area after the Tuareg uprising led to a military coup that plunged Mali into chaos.

Insecurity persists however, and though the violence, often blamed on the remnants of Islamist groups, is generally focused in the desert north, attacks have in recent months crept further south.

Dozens of suspected Islamist militants attacked a police base near Mali's southern border with Ivory Coast earlier this month.