Ottawa (AFP) - Canadian special forces participating in military training in southeast Niger, near the border with Nigeria, were ordered to withdraw recently to avoid battling with Boko Haram Islamists, the military said Thursday.

The troops had been posted to the town of Diffa, where the government of Niger declared a state of emergency on February 11 following attacks in the region that borders Boko Haram's stronghold in northeast Nigeria.

The Canadians are participating in US-sponsored counterterrorism training that started on February 16 and is due to wrap up on March 9.

The annual program has 1,300 troops from 19 countries training militaries in five African countries in shooting, movement, communications, and mission planning.

Dominique Tessier from Canada's defense department did not say how many Canadians were at risk of confrontation with Boko Haram, but noted in an email to AFP that "several members" were relocated from Diffa to other areas such as Agadez and Niamey in Niger and N'Djamena in Chad "due to security issues."

"This was seen as a prudent measure given the current security situation in the region," Tessier said, adding the exercise continues.

"Recent events in Niger involving Boko Haram do highlight training such as this to help collective efforts against violent extremist organizations."

The Canadian special forces also stand ready to provide humanitarian or other assistance, should Ottawa decide to offer help, Tessier said.