An American man was wrongly flagged for deportation by the Immigration and Customs Enforcement agency — and a local sheriff's department held him for weeks because of it.

Peter Brown is suing the Monroe County Sheriff's Office in Florida over the detention, accusing the department of violating his constitutional rights.

His lawsuit alleges that his repeated attempts while jailed to prove he was a citizen fell on deaf ears.

An American man spent weeks in a local jail after he was wrongly flagged for deportation by the Immigration and Customs Enforcement agency and detained by the local sheriff's department, according to a lawsuit filed by the American Civil Liberties Union.

Peter Brown, who was born in Philadelphia and lives in Florida, was jailed in April 2018 over a probation violation after he tested positive for marijuana. But in a bizarre twist, the Monroe County Sheriff's Office refused to let Brown go even after a judge ordered his release.

The officers told him he was instead being held on an ICE detainer request, and that he would soon be transferred to a prison in Jamaica, a country he has only seen once while on a cruise, according to the ACLU.

"I thought it was a joke honestly at first, or just some odd fluke because it made no sense," Brown told NPR.

According to Brown's lawsuit, which names Sheriff Richard Ramsay as the sole defendant, the sheriff's department had fingerprinted him and sent it to ICE, which incorrectly identified him as an unauthorized Jamaican immigrant, then flagged him for deportation.

The sheriff's department has a Basic Ordering Agreement with ICE, which pays the department $50 for each detainee it holds at ICE's request — and Brown said his repeated attempts to explain to officers that he was an American citizen fell on deaf ears.

"Throughout his detention, Mr. Brown repeatedly told the Sheriff's officers that he was a US citizen and could not be deported or held for ICE," the lawsuit said.

It continued: "He offered to produce his birth certificate. His friend and co-worker called the jail on his behalf to explain his citizenship. He filed multiple written grievances explaining that he was born in the United States. The Sheriff's own jail file showed that he was a US citizen born in Philadelphia and had a valid Florida driver's license.

Read more: ICE is partnering with 18 more sheriff's departments to ramp up its deportation machine

'Between you, your attorney, and ICE'

In this March 3, 2015 photo, Immigration and Customs Enforcement officers escort an arrestee in an apartment building, in the Bronx borough of New York, during a series of early-morning raids. Associated Press/Richard Drew

In a written response to one of Brown's complaints, the sheriff's department said, "It is not up to us to determine the validity of the ICE hold. That is between you, your attorney and ICE."

Sheriff Ramsay told NPR in a statement that his hands had been tied in Brown's case.

"When an inmate is held under an ICE matter, I, as Sheriff do not have legal authority to release that person," he said.

The ACLU, however, disagreed.

"The $50 payment the Sheriff's Office receives under the BOA does not excuse the sheriff from complying with the Constitution," the lawsuit said.

Once Brown was physically transferred from the sheriff's custody into ICE custody, the agency examined his documentation and released him immediately.

Brown's case is far from the first time that a US citizen has been wrongfully detained or flagged for deportation by ICE — the Deportation Research Clinic at Northwestern University found that more than 250 individuals were wrongfully held over six years, its director told NPR.

One American was even detained for 1,273 days, amounting to nearly four years, the Los Angeles Times reported.

"It's shocking and not right that somebody can lose their human rights and have all dignity stripped away simply because someone delivers a piece of paper or signs a form," Brown said in a statement.