Baghdad: Their names spread terror across Daesh’s so-called “caliphate”, but senior militants now languish in Iraqi prisons, subjects of mockery for the populace they ruled.

Once boasting nicknames like the Black Box and the Butcher of Mosul, the defeated Daesh commanders now draw vitriol on social media while news outlets have published selfies taken by Iraqi soldiers of them being captured or marched handcuffed in prison uniforms.

Following Daesh’s ouster from second city Mosul last July, Iraqi forces went on the hunt for Daesh fighters who had fled the battlefield.

Researchers estimate they have since put behind bars some 20,000 suspected members of the group.

The search involved digging through the rubble of war-torn Mosul and hunting through the tunnels and hideouts the militants had created during their three-year reign.

It was in Mosul’s Old City, near the Al Nouri mosque where the self-proclaimed “caliph” Abu Bakr Al Baghdadi made his only public appearance, that the elite Counter-Terrorism Service found the senior commander nicknamed the “Black Box of Daesh” - a moniker that came from his lynchpin role in the organisation.

Nizam Al Deen Al Rifai had sent gunmen and suicide bombers in a desperate bid to repel government troops, said Sabah Al Noman, spokesman for elite units that spearheaded the Mosul offensive.

But in the end he had no choice but to surrender.

Cornered by government soldiers, he left his underground hideout bare-chested, his unkempt beard matching his white hair.

Time was finally up for the notoriously hardline head judge of the “caliphate” which at its height ruled over roughly seven million people in Iraq and Syria.

The 60-year-old Mosulite is still under interrogation, Noman said, adding that he could still give up valuable information about Daesh.

Rifai’s position made him the group’s third in command, according to security sources speaking on condition of anonymity.

He also had the symbolically important role of “teaching theology to Abu Bakr Al Baghdadi,” the militants’ self-proclaimed “caliph”, they said.

Another infamous Daesh member, Mufti Abu Omar (whose real name is Ezz Al Deen Taha Ahmad), spread terror far beyond Mosul through the group’s propaganda efforts.

In one gruesome video, he appeared in military uniform.

Sporting a kalashnikov rifle he ordered young people, suspected of being gay, thrown from the roof of a building to their deaths.

That clip and others earned the 62-year-old Iraqi the nickname “Butcher of Mosul”.

Today, he is in the hands of the country’s security forces, who nickname him “White Beard” - facial hair he trimmed as he tried to disguise himself as troops approached.

He escaped, like many militants, by mingling with the flood of civilians fleeing the battle-scarred city centre.

He hid in a house in the city’s east, never leaving for fear of being recognised, provincial council security official Mohammad Ebrahim said.

“A neighbour saw him and informed the security forces,” he said.

Today, the “Butcher” is a subject of derision and hatred on social media.

“He terrorised all of Mosul by stoning people to death,” wrote one user.

“Today the people of Mosul should take him to a public place and beat him to death with their shoes.”

Some of those now detained were among the wave of foreigners who flocked to Daesh.

While his comrades enforced Daesh rule, Abu Hamza Al Beljiki was preparing for the future.

According to investigators, he was in charge of the “cubs of the caliphate” - about sixty children aged eight to 13 who received intensive fitness and weapons training.

Abu Hamza is the nom de guerre of Tarik Jadaoun, a Belgian fighter with Moroccan roots, who joined the group in 2014.

After appearing in videos calling for attacks in Europe, he earned the moniker “the new Abaaoud”, after his compatriot Abdul Hamid Abaaoud, one of the organisers of the November 2015 attacks in Paris.

Currently detained and awaiting trial, he faces charges under Iraq’s terrorism law, that have already seen several Europeans receive the death penalty.

According to statements by Iraqi justice officials, he made a detailed confession to his jailers.