As an economist, Hussein Mahrammi helped U.S. development authorities in Kabul, Afghanistan rebuild his war-torn country. He planned to stay in Afghanistan. Then, one by one, his colleagues were assaulted and even killed because they worked with Americans.

"We really feel afraid," Mahrammi says.

So Mahrammi applied for a Special Immigrant Visa, or SIV. It was created specifically for people who worked with the U.S. government or contractors in Iraq and Afghanistan, at great risk to themselves. In return, they were promised green cards, though some did not get the warm welcome they expected. Immigrant rights advocates say these visa holders have been detained and threatened with deportation since President Donald Trump took office.

"I was expecting or dreaming that they welcome in a way," Mahrammi says, "maybe through some separate line, offering us tea, and welcome us. But it was not like that."

Needless to say, Mahrammi was not offered tea when he landed with his wife and four young sons at Dulles International Airport in Virginia earlier this month. Officers from U.S. Customs and Border Protection pulled Mahrammi aside. The officers started asking a lot of questions. Finally, after five hours, Mahrammi and his family were allowed in.

But his case could have gone very differently. That same week, another SIV holder from Afghanistan landed at the airport in Newark, N.J.

"Once he arrived, he was put into detention, questioned without a lawyer, and forced to sign papers he didn't want to sign," says Alexander Shalom, senior staff attorney with the American Civil Liberties Union of New Jersey. He's representing the man known in court papers only as John Doe, to protect his privacy.

Hours before the man was set to be deported, his lawyers raced to court. One federal judge ruled against them. So they asked for an emergency hearing before the Third Circuit Court of Appeals.

"The government was planning to put him back on a plane," Shalom says, "until we got the Third Circuit to prevent them from doing that." That man is still in detention. Federal authorities have yet to tell the ACLU why they won't let him into the country.

Also this month, in Los Angeles, officers detained a family of five travelling on a special immigrant visa. They were eventually released, but only after an emergency court order.

"What seems to be going on is a tremendous amount of discretion being given to these CBP agents, without much guidance," says attorney Robert Blume of the firm Gibson, Dunn and Crutcher, which is representing the family.

A Customs and Border Protection spokeswoman declined to comment on individual cases.

The Trump administration is making it tougher to get visas from certain parts of the world, and has vowed to ramp up screening of people entering the U.S. A CBP spokeswoman says the agency has not changed its policy on SIV holders since January. But immigrant rights groups say officers with CBP have become too aggressive at airports and border crossings.

"I would assume that there are dozens, if not hundreds more cases, that nobody ever finds out about," says Becca Heller, director of the International Refugee Assistance Project. Heller is trying to document cases of people attempting to enter the U.S. legally, and being turned away. She didn't find a single example of SIV holders being detained or deported by CBP officers — until this month.

"It just begs the question of whether what they're doing is based on actual actionable intelligence, or just on the fact that they are sort of running amok right now," says Heller.

But David Aguilar, a former acting commissioner of CBP, disputes that.

"What it tells me is that Customs and Border Protection is doing what they have been charged with doing," says Aguilar. He says a visa alone doesn't guarantee entry to the U.S. The law specifies 60 different grounds for a border protection officer to reject someone. Aguilar says those officers are even trained to look at body language.

"If the officer believes the individual is nervous, is evasive, eye contact is not there, or the line of questioning just does not match up with the answers," Aguilar says, officers are trained to ask more questions. "If they are not allowing immediate entry into the U.S., there is a reason for it," he says.

Immigration advocates say it's not easy to get an SIV in the first place. The process involves extensive background checks by the Departments of State and Homeland Security. In the case of Hussein Mahrammi, it took two years.

A week after landing in the U.S., Mahrammi and his family still don't have any furniture at their apartment in Maryland. So they're sleeping on the rugs they brought with them from Kabul. Mahrammi isn't complaining. If his family had to go back to Afghanistan now, he says, they'd become targets.

"This time, much in danger," Mahrammi says. "Because we would be clear and distinguished target."

Mahrammi says he's grateful to be in the U.S. Where his family doesn't have to live in hiding anymore.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.