For noncitizens, minor crimes like shoplifting can result in deportation. But a growing number of district attorneys say they offer immigrants accused of crimes plea deals to help them avoid that fate.

The prosecutors, including at least six in jurisdictions on the East and West coasts, purposely avoid reaching plea agreements or sentences that might trigger a noncitizen’s deportation or prevent his or her re-entry into the country. It is an arrangement that proponents say protects some noncitizen immigrants from the disproportionate consequences of minor convictions, but critics, including U.S. Attorney General Jeff Sessions, contend is unethical because it treats citizens and noncitizens differently.

These local prosecutors, who have significant discretion in how they charge crimes, say they are also promoting public safety by courting immigrant constituents’ trust. “I saw what were, in my opinion, many miscarriages of justice,” said Acting Brooklyn District Attorney Eric Gonzalez, of immigrants deported as the result of low-level convictions. His office recently adopted a policy of considering and trying to minimize the immigration impacts of convictions and hired two immigration attorneys to train his staff.

One of his inspirations, he said, was a Brooklyn man arrested for being unescorted in an apartment building. At the precinct, police officers discovered the man had a small amount of crack cocaine. In court, the man, a green-card holder from Haiti, pleaded guilty to drug possession. When he tried to come home after visiting Haiti, border officials wouldn’t let him return.

Under the new policy, prosecutors might have offered the green-card holder a trespassing plea, which wouldn’t have triggered immigration problems, instead of drug charges, which typically do.