Nouakchott, Mauritania (CNN) -- The Mauritanian army responded to an attack Tuesday by a terrorist group aligned with al Qaeda by mounting a counterattack in northeastern Mauritania that killed about 20 members of the group and captured nine others, military sources told CNN.
The incident occurred Tuesday afternoon, when 25 vehicles carrying fighters belonging to al Qaeda in the Islamic Maghreb attacked the Mauritanian military base in the city of Bassiknou along the border with Mali, the sources said.
The clash lasted 45 minutes, area residents said.
Afterward, the Mauritanian army pursued AQIM fighters into Mali, the sources said.
"We heard violent explosions and gunfire near the military base here in Bassiknou; a state of panic was prevailing," a witness told CNN. "It seems that al Qaeda decided to retaliate after losing many of its fighters in the clashes of Wagadou forest ... when Mauritanian troops destroyed their camps."
He was apparently referring to an incident that occurred last month, when Mauritanian special forces joined troops from Mali in launching an offensive targeting what they called an al Qaeda base camp.
According to Mauritanian army officials, 15 al Qaeda militants were killed in the offensive. Two Mauritanian soldiers were killed and another five were wounded.
The June fighting occurred about 70 kilometers (45 miles) across the Mauritanian border in Mali's Wagadou Forest, Mauritanian army spokesman Col. Teyib Ould Brahim said. It was launched after Mauritanian military leaders decided "to sweep the area, where a well-protected armed camp threatened the security of our country," according to the spokesman.
Mauritanian soldiers, at times with assistance from France's government and others, have gone after alleged terrorists numerous times in recent years. That includes an incident last July, in which Mauritanian soldiers killed six militants near the Mali border, Interior Minister Mohammed Ould Boilil said at the time.
Days later, a man claiming to be Abu Musab Abdul Wadud, the head of al Qaeda in the Islamic Maghreb, said in a video that the terrorist group had captured and executed 78-year-old French movie director Michel Germaneau in retaliation.
The organization has voiced its intention to attack Western targets and taken responsibility for several terrorist attacks in recent years, according to the Council on Foreign Relations. The think tank says that al Qaeda in the Islamic Maghreb, born and once focused in Algeria, has broadened its scope to become "more global, sophisticated and better-financed." Its leaders are mainly Algerian, while its foot soldiers increasingly come from the Sahel region of Mali, Niger and Mauritania.
In January, the Council of the European Union warned of "the growing threat in the region (of north and west Africa) from organized crime and terrorist networks, in particular al Qaeda in the Islamic Maghreb."
Chad President Idriss Derby told the magazine Jeune Afrique this year that the al Qaeda branch has become even more of a threat of late. He said militants have taken advantage of unrest in Libya by seizing surface-to-air missiles from military stockpiles in rebel-held areas.
"Al Qaeda in Maghreb is on the way to becoming a veritable army, the best equipped in the region," Derby said.
U.S. military officials have not publicly weighed in on the claim from Derby, who offered no evidence. A more plausible scenario, according to New America Foundation researcher Andrew Lebovich, is that al Qaeda's revenues from kidnapping, drug smuggling and human trafficking have enabled it to buy such weaponry on the black market.
Journalist Ould Abdel Wedoud Mohamed Yahya contributed to this story.