Protestors hold a placard as they gather behind barbed wire during the End Bad Governance protest in Abuja on August 1, 2024. [AFP]

Nigeria's President Bola Ahmed Tinubu has ordered the release of children jailed for taking part in widespread anti-government protests whose frailty during their court appearances sparked outrage, a minister said on Monday.

On Friday, 76 Nigerians, many of them minors, were taken to court in the capital Abuja to stand trial nearly three months after their arrest for taking part in demonstrations against the country's economic crisis.

Videos showed several youths -- to all appearances underage -- sitting or lying on the courtroom floor, holding their stomachs.

The images provoked an outcry on social media from politicians and civil society alike, reigniting debate over their detention conditions and police violence.

"The President has directed that these children, these minors, (be) released immediately," Information Minister Mohammed Idris told the press on the sidelines of a meeting between Tinubu, British Foreign Secretary David Lammy and his Nigerian counterpart Yusuf Tuggar.

Tinubu "also directed that all the law enforcement agents involved in the arrest and the legal processes will be investigated", Idris added.

He also vowed "disciplinary action" if "there are any infractions found to have been committed by any official of government".

At least 21 people have been killed by the Nigerian security forces in this year's protests, dubbed "#EndBadGovernance", according to rights group Amnesty International.

In the face of the outcry, the Nigerian Inspector General of Police's office denied officers subjected the detainees to ill-treatment, warning that "age does not exempt individuals from facing legal consequences".

"Medical aid was promptly provided to these individuals," the office said in a statement, "demonstrating the Police Force's commitment to the welfare of those in its custody".

On Friday, police spokesman Muyiwa Ogunjobi told Nigerian television that "once you are more than seven years old you can be" arraigned.

More than 700 demonstrators taking part in the protests have also been arrested, Amnesty says.

Police violence has long been a contentious issue in Nigeria, especially in the aftermath of the EndSARS protests in October 2020 calling for the dismantling of a police unit infamous for its brutality.

On October 20, 2020, police and soldiers opened fire on a peaceful rally in Lagos, putting down the biggest anti-government demonstrations in recent Nigerian history.

At least 12 protesters were killed, according to Amnesty.