Nigeria has begun the prosecution of more than 500 people accused of involvement in militant attacks in one of the country's largest ever terrorism trials.

The suspects face charges linked to aiding and abetting terrorism, particularly in the north-east where an insurgency by the Boko Haram Islamist group began 17 years ago.

Since then, insecurity has spread to many other areas of the West African nation, leaving communities, often those in rural areas, at the mercy of mushrooming militant groups and gangs that kidnap for ransom.

The mass trial opened on Tuesday at a high court in the capital, Abuja, where 227 suspects were arraigned before 10 judges, according to Attorney General Lateef Fagbemi.

Hundreds of people have lost their lives in bombings and various attacks across Nigeria this year alone.

Very few people are ever prosecuted over terror attacks - and suspects are often detained and spend years in custody without facing trial.

According to the AFP news agency, gunmen killed at least 20 people on Wednesday in the western state of Niger. Residents say the attackers raided villages in Shiroro district, an area where kidnapping gangs and Islamist militants are known to operate.

Security was tight during the court session on Tuesday, with suspects transported in heavily guarded convoys under military, police, and intelligence supervision. International observers, including human rights groups and the Nigerian Bar Association, were also present in court.

The defendants are alleged to have taken part in attacks mainly in northern Nigeria, while others face charges of supporting militants through funding, supplying arms, and logistics.

Five of the accused have already received varying jail terms - from seven to 20 years - after pleading guilty to charges that included selling livestock, supplying food, and providing information to militant groups.

Fagbemi stated that the scale of the operation demonstrated the government's resolve to deal with the matter, asserting, The federal government is committed to ensuring that due process is followed while bringing those involved in terrorism to justice.

Security expert Bashir Galma, a retired army major, described the trial as a positive development and a significant milestone in Nigeria's fight against terrorism. Many believe it will provide some measure of peace for families impacted by these violent acts.