HAMMAM AL-ALIL CAMP, Iraq (Reuters) - The Iraqi intelligence officer kept barking the same question at the 46-year-old man who was looking nervously at his hands after having escaped Mosul: "Why do you still have a beard?"
Having walked with his wife and children across frontlines in Iraq's second-largest city, dodging gun fights between Iraqi forces and Islamic State, the man, Mohammed, was hoping for a tent and the chance to rest in the crowded Hammam al-Alil camp for displaced people.
Instead he ended up being interrogated and then detained - a fate shared with an estimated 2,000 others accused of having ties to the Sunni Muslim militants, according to human rights activists.
Up to 2,000 people flee Mosul every day as government forces close in on besieged Islamic State fighters in the western half of the city, their biggest remaining stronghold in Iraq.
The exodus has put pressure on the security forces to root out any militants posing as displaced people in order to escape or stage suicide attacks.
Every adult male coming to Hammam al-Alil camp -- the arrival point for the displaced -- is led to a fenced compound where officers inspect their identity cards and check them against a database of Islamic State suspects.
But human rights activists and residents say the database is not only based on evidence but also personal grudges and -- in the case of Mohammed -- mere appearances. Beards were mandatory under the Sunni Muslim militants who took control of the city in 2014.
"Sir, I haven't had time to shave yet. I was running away," the man kept saying as his wife and children were kept in a separate fenced area.
"Where are you from? What were you doing under Daesh (Islamic State)?" the officer demanded as Mohammed looked at the ground during an interrogation witnessed by Reuters.
Not satisfied with the answers, the officer sent him to a converted shipping container for further questioning, even though his name was not in the computer.
"He comes from Babel, a village outside Mosul where Daesh snipers have been hiding in farms shooting at civilians," the officer said, explaining his decision. "Before he can go we need to check with our colleagues there what he did under Daesh."
Security checks had started when Mohammed arrived at the first army checkpoint outside Mosul. There he was put with dozens of others on a bus to Hammam al-Alil.
Most displaced people stay just two hours at the fenced compound to see their papers verified, while being offered water and food before getting a tent or a lift to another camp.
But up to 30 are arrested every day for suspected militant ties, said Lieutenant General Bassam Hussein Ali, head of joint security operations to evacuate displaced people from Mosul. "Daesh is sending people to camps, so we need to filter them."
New York-based Human Rights Watch (HRW) estimates some 1,200 have been detained and at least 700 others sent to Baghdad for prosecution, though it is not known yet if any have been convicted.
Laith Mohammed, a senior intelligence officer at Hammam al-Alil, said trusted officers and sources who had fled Mosul had compiled lists of whose who had worked with Islamic State.
He pointed to two policemen who were screening some 40 men seated next to each other on the ground.
Ali, the head of security operations, said each suspect would ultimately be referred to a judge "to be punished in accordance to the guilt he has committed".
"We only check names of the males on computers and if it appears that the names are on the wanted list of the security forces, we separate him from his family and we inform his family that he will be detained for interrogation," he said.
But HRW's senior Iraq researcher Belkis Wille said two directors of prisons in Hammam al-Alil and Qayyarah, also located south of Mosul, had told her they believed a third of their inmates were innocent -- often held because they had similar names to wanted people. One watchlist contained some 80,000 suspects.
Others were jailed because of false accusations motivated by personal quarrels.
"Often there is simply a land dispute, or tribal dispute or family dispute," said Wille. "Often it's about women. Some guy wanted to marry the sister of some other guy."
Major General Haydar Youssef Abdalla, head of the elite squad in Iraq's Federal Police, said to avoid wrongful accusations, people making allegations needed to provide witnesses.
The security checks don't end in the camp, home to 30,000 displaced.
Whoever is allowed to travel on to relatives living in a safer part of Mosul needs another permit to leave the city. Queues form at road checkpoints where people have to stop to show their papers.
Separate security clearance is needed to reclaim money stuck in a bank, or salaries for public servants held up by the government.
"How do you draw the line? I had Daesh members buying from my shop so now I am seen as a Daesh follower," said Ali Hassan, a light bulb shop owner who has returned to eastern Mosul, which is fully under army control.
"If I had refused, Daesh would have arrested me. It's unfair to make us all Daesh suspects."
Additional reporting by Ahmed Aboulenein; Editing by Mark Trevelyan