Nearly 400 people have been sentenced in Nigeria for links with militant Islamic groups following mass trials.

The convicts were given sentences ranging from five years to life imprisonment after being linked to Boko Haram or a rival splinter group, the Islamic State West Africa Province (Iswap).

The trials came at a time when the government is under intense pressure to curb rising insecurity in Africa's most-populous state. Security forces are battling multiple armed groups, from militant Islamists to separatists, and kidnapping-for-ransom gangs.

Boko Haram launched an insurgency in the north-east in 2009, killing tens of thousands of people and displacing more than two million, aid groups say.

On Wednesday, the US urged its citizens to reconsider travelling to the country due to the deteriorating security situation.

More than 500 suspects were put on trial in the federal high court in the capital, Abuja, on charges of either taking part in attacks or supporting the militants through funding, supplying arms, or giving logistical support.

On Friday, judges convicted 386 of them, while two were acquitted, eight were discharged, and the cases of 112 suspects were adjourned, officials said.

Five of the accused had pleaded guilty at the start of the trials to charges that included selling livestock, supplying food, and information to the militant groups.

The US carried out airstrikes in northern Sokoto state on Christmas Day to target a militant Islamist group known as Lakurawa after President Donald Trump alleged that Christians were being persecuted in Nigeria. The government denied Trump's claim, stating that all faiths and non-faiths have been victims of violence.