Carlos was arrested after a traffic stop in Jenks, Oklahoma, in May, 2017, on drug charges, speeding, driving with a suspended license, and having windows that were too tinted.

The charges against Carlos, who was given a pseudonym for this story, were later dropped but he remained in a Tulsa jail for two reasons: he is an undocumented immigrant and ICE was paying to keep him there.

In most counties, after charges are dropped against an undocumented immigrant, Immigration and Customs Enforcement can place a detainer on them, which local authorities can choose to honor. If the sheriff honors the detainer and the person is detained by ICE, they are transferred out of jail and to an ICE facility. If the detainer isn’t honored or ICE agents don’t arrive in time to detain the arrestee, the person is free.

In Carlos’s situation, he stayed in jail thanks to a contract the sheriff’s department has with ICE. This contract, known as an intergovernmental service agreement (IGSA), allows the jail to hold undocumented immigrants for ICE and pays $54.13 per inmate per day, according to an ICE document obtained by the Detention Watch Network, an organization that advocates against immigrant detention.

That would amount to more than $3,000 for the sheriff’s department keeping Carlos for two months.

According to Detention Watch Network, the Tulsa jail held an average of 166 ICE detainees on any given day in 2017—meaning it would have collected about $3.3 million during that time.

Separate from its ICE contract, Tulsa also participates in the federal government’s 287(g) program, which permits sheriff’s deputies to make immigration arrests against people who are already in their custody for other suspected crimes. While the 287(g) program does not bring in revenue on its own, local governments that have 287(g) agreements and detention contracts are paid by ICE to detain the people they arrest on immigration charges. Some activists say this rewards immigration arrests.

"You’ve essentially financially incentivized people to be entered into the detention pipeline through the 287(g) agreement because the localities can actually make money per person per day on the backside,” said Mary Small, the policy director at Detention Watch.

Carlos’s wife said he experienced poor conditions in jail, like lights were on all night and “deplorable” food including watery oats and pre-cooked potatoes. The thin mattress he slept on exacerbated back problems he suffered for years, she added. She isn’t alone in her complaints. An ICE report from March shows that the Tulsa facility did not meet 9 out of 16 jail standards including standards for food service and environmental health and safety.

There was no proof food service staff was “medically cleared,” according to the report.

The 2017 ICE document obtained by Detention Watch shows that 21 counties that currently have 287(g) programs also have immigration detention contracts. In 2017, the contracts were worth about $25 million combined. Of the 21 counties, 13 have contracts directly with ICE and the other 8 have subcontracts through the U.S. Marshals Service. (A Marshals Service spokesperson said the agency does not receive any of the money from these contracts.)

The 21 counties with both programs held about 1,074 detainees on any given day, though some average 0 detainees and one averages as many as 300, according to data from Detention Watch. They are paid between $41.03 and $124.78 per inmate per day.

How much individual counties make yearly varies. Bristol County, Massachusetts, made the most by far, raking in about $6.2 million last year for holding an average of 175 immigrants at a rate of $98 per inmate per day. It is followed by Etowah County, Alabama, whose contract was worth $4.9 million for housing an average of 300 immigrants.

In some places, these programs, particularly 287(g), are meeting local resistance. In Mecklenburg, North Carolina, the county’s 287(g) program was hotly debated in the Democratic primary for the county sheriff. Incumbent Irwin Carmichael touted the program while two challengers opposed it.

“The whole purpose of this is safety and security,” he said, according to the Charlotte Observer. “This is a tool for us to know who’s in our community and who’s in our facilities.”

In the three-man race in May, Irwin finished dead last. NBC News called the vote a ”referendum” on whether 287(g) made the community safer.

The election’s winner, Garry McFadden said 287(g) “damages the relationship between law enforcement and the community."

In places like Tulsa, however, immigration enforcement still generates fear for people like Carlos’s wife.

“I’m afraid that at any moment, the police will stop me, arrest me,” she said. “And my kids, what will become of my kids?”