Three U.S. Army special operations commandos and several soldiers from Niger were killed Wednesday when they came under "hostile fire"  in the west African country, the U.S. military said.

The commandos, who were Green Berets, were likely attacked by militants from al-Qaeda in the Islamic Maghreb — the North African branch of the extremist group — in southwestern Niger,  near the border with Mali, the AP said. 

A handout file photo made available by the U.S. Army on Oct. 5, 2017, shows Nigerien service members reacting to contact during Exercise Flintlock 2017 in Diffa, Niger, March 3, 2017.

Two  U.S. commandos who were wounded in the attack were taken to the capital of Niamey and were in stable condition, the Associated Press reported.

U.S. Africa Command said the forces were on a joint U.S.-Nigerien patrol when they were attacked. 

U.S. forces are in the country to provide training and security assistance to Niger's military in their fight against extremists. 

President Trump was notified of the attack Wednesday night as traveled to Washington from Las Vegas, the White House said. Trump had been meeting with victims of the mass shooting that killed at least 58 people Sunday night, along with first responders and doctors.