On a typical day the Frederick county detention center in Maryland holds 51 undocumented immigrants who earn the county more than $4,000 a day from their cells.

For Frederick county’s sheriff, Chuck Jenkins, a Trump ally who Fox News calls America’s second-toughest sheriff on immigration, those Immigration and Customs Enforcement reimbursements have turned into a goldmine – both fiscal and political.

Jenkins’ office, which manages law enforcement in this 240,000-person county, houses detainees on Ice’s behalf – an arrangement that sees his office collecting $83 per detainee per day through a deal meant to offset detention costs.

Sheriff David Clarke Jr: the black Democrat who is Trump's favorite cop Read more

But the actual cost of housing a detainee in the county lies between only $17 and $53 a day, according to the sheriff’s office and a county audit respectively. That means housing the detainees generates a tidy profit, something that Jenkins sees as a source of pride and a political weapon in an era when a crackdown on illegal immigration has raised the passions of the Republican base.

“The reimbursement has far, far, by millions of dollars, exceeded the actual cost of housing,” Jenkins told the Guardian.

Jenkins’ detention center deal is a valuable source of revenue for a department with an annual budget under $50m, but it has not always run smoothly. A 2013 inspection by Ice’s office of detention oversight found Jenkins’s office non-compliant with agency standards on 20 counts, including unmonitored access to legal representatives, timely provision of healthcare, interpretation services, food safety and documentation of detainee grievances.

Jenkins’ reputation as a conservative firebrand has earned him comparisons to Joe Arpaio, the Arizona sheriff pardoned by Donald Trump for a contempt-of-court conviction. Since his election, Jenkins has spoken at “Take America Back” rallies and Tea Party events, travelled to the US-Mexico border with funds from ultra-right anti-immigration group Fair and campaigned against perceived threats to the United States from socialism and immigration.

But the funds he generates from Ice – and a raft of other controversies – have now become a source of contention for Jenkins, who faces a vocal challenge from Democrat Karl Bickel in November and could potentially halt the further rise of such an up and coming anti-immigrant figure.

Sign up for the new US morning briefing

Bickel, a justice department policing expert and former second-in-command at the sheriff’s office, says Jenkins “manages through fear and intimidation” and preys on public concerns about gangs and immigrants that actually have little real impact on life in this patchwork of relatively well-off rural and urban communities, just an hour’s drive from the White House.

“He considers himself the new Joe Arpaio,” Bickel said. “He loves to be on Fox News. And all he does is talk about problems that aren’t really problems here.”

Bickel promises to audit the detention program, as well as the county’s agreement with Ice – one of nearly 80 such deals deputizing county law enforcement to conduct raids and detentions on Ice’s behalf.

An enthusiastic Trump supporter, Jenkins chaired the Frederick county Republican party central committee for five years prior to his election as sheriff. Jenkins’s growing profile has brought him into Trump’s circles: the sheriff attended a meeting on immigration enforcement with the president earlier this year. He also spoke alongside Arpaio and Trump – and Iowa congressman Steve King – at a September “angel families” rally meant to spotlight crimes committed by undocumented immigrants. The president, Jenkins said, “appreciates my view and my stand”.

Facebook Twitter Pinterest Inmates in Maricopa county, sheriff Joe Arpaio’s jail in Phoenix called the Tent City Jail, one of Arpaio’s most acclaimed and notorious creations. Photograph: Charlie Riedel/AP

But Frederick county is in the midst of a demographic and economic transformation – one that Bickel believes could help him oust Jenkins as sheriff. Despite losing a 2014 challenge, Bickel now has the backing of the county’s firefighters’ union and public education unions. His campaign coffers are on par with Jenkins’.

Missy Dirks heads the Frederick county teachers association, whose members voted to endorse Bickel. She calls Frederick a “purple county”. Its government mixes Republicans and Democrats, its president is an independent and it’s increasingly diverse.

“We’re changing,” Jenkins also acknowledged, “from what was a largely Republican county to what is more narrowly Republican.”

Still, Jenkins’s biggest donors are county power players: a Frederick county prosecutor and circuit court judge, along with prominent local attorneys and business owners, none of whom responded to interview requests from the Guardian.

Jenkins says he encounters supporters daily, including native-born and naturalized citizens. “Most of that,” he said, “is based on the fact that we’re doing something about the illegal immigration.” He touts four years of falling crime in the county, along with 1,600 total deportations, as key accomplishments.

Bickel points out that neighboring counties without Ice agreements, have seen larger drops in crime, despite greater immigrant populations. From 2008 to 2016, the latest year for which data is available, crime in neighboring Montgomery county fell 44%, in Howard county by 39% and in Frederick by just 30%. And he argues that any profit generated by the detention agreement must be returned to the federal government – and might be offset by millions of dollars in settlement payouts made by Jenkins’s office following controversial arrests and deaths.

Facebook Twitter Pinterest Local immigrants rights groups protest after former Arizona sheriff Joe Arpaio was pardoned by Donald Trump on 25 August 2017 in Phoenix, Arizona. Photograph: Caitlin O'Hara/Reuters

Last month, a federal appeals court held Frederick county liable for the improper detention of Roxana Orellana Santos. Sheriff’s deputies demanded papers from Santos, a county resident, while she ate lunch outside her workplace. In April, the county agreed to a $1.9m settlement with the family of Robert Ethan Saylor, a 26-year-old man with Down’s syndrome who died in a confrontation with sheriff’s deputies after attempting to remain in a Frederick movie theater for a second screening of the film Zero Dark Thirty.

Trump has committed to expanding local cooperation with Ice, which increasingly relies on what SUNY Buffalo immigration law professor Rick Su calls a “political patchwork” of county-level agreements. Although Ice’s budget and personnel have increased under Trump, Su says the agency needs local support to maintain the record-high detention and deportation numbers first reached in the Obama era.

Trump and Arpaio: the bromance that led to the presidency and a pardon Read more

But for local law enforcement, Su says, acting on Ice’s behalf can be a difficult choice. “When [Ice] sweep into an immigrant community, conduct raids, turn everything upside down and leave, they don’t care what happens the next day. Local law enforcement does,” he says, and often struggles to rebuild relationships in frightened communities.

As Ice seeks to expand enforcement, debates about the agency’s actions have become volatile and increasingly important, both for the agency and for politicians and law enforcement in affected counties. Although Bickel and Jenkins are debating a range of issues – the opioid crisis, arming teachers, added training for sheriff’s deputies – it’s the county’s all-out approach to immigration enforcement that has brought national attention to Frederick county.

“This dependency [Ice] developed has opened up the kind of political fight you’re seeing in the county right now,” Su says. “I don’t think they want that. They don’t want it to be a local political battle, jurisdiction by jurisdiction, county by county, overlaid with all the concerns that come with that.”