Immigration lawyers in Miami-Dade County are challenging its practice of jailing people on behalf of federal immigration authorities, in a case that could test the Trump administration’s attempts to pressure so-called sanctuary cities and counties.

In a lawsuit filed Wednesday in Federal District Court in Miami, lawyers representing a local resident, Garland Creedle, argued that the county had violated his Fourth Amendment right against unlawful seizure.

The practice at issue is one in which federal immigration authorities send requests, known as detainers, to local police departments or jails asking them to hold people they are about to release so that immigration authorities can go arrest them. During his first week in office, President Trump signed an executive order threatening to withhold billions of federal dollars from cities and counties that ignored detainers, saying that such places, sometimes known as sanctuary cities, were helping to harbor dangerous criminals.

Shortly after Mr. Trump signed the order, the Miami-Dade mayor, Carlos A. Giménez, directed his corrections department to honor the requests, saying the county could not afford to lose funding. So after Mr. Creedle, 18, posted bail in March in a domestic dispute case, which was later dropped, he was held in custody overnight on the suspicion that he was an undocumented immigrant.

The detainer was not only unconstitutional, Mr. Creedle’s lawyers said, but also uncalled for. Mr. Creedle was born in Honduras but gained United States citizenship through his father, who is also a citizen. The government let him go once it realized the mistake.

“It goes to show just how sloppy this is,” said Rebecca Sharpless, a lawyer representing Mr. Creedle and the head of the University of Miami Law School’s immigration clinic. “What immigration does is check a box on a boilerplate form saying they have probable cause to hold someone in custody, and that is supposed to be constitutionally sufficient to detain them.”

“That’s what we’re saying is wrong,” she said.

The case could test an argument that many immigration lawyers and sanctuary cities have made: that detainers may violate the Fourth Amendment because they do not carry the same burden of proof as, say, an arrest warrant signed by a judge.

Nestor Yglesias, a spokesman for Immigration and Customs Enforcement in Miami, said the agency could not comment on Mr. Creedle’s case because of the pending litigation. In general, he said, “ICE lodges detainers on aliens who were arrested on local criminal charges when the agency has probable cause to believe an alien is removable from the United States.” He said that ICE officers were trained on how to meet the standard of probable cause.

The case in Miami also demonstrates the quandary confronting law enforcement agencies in the Trump era: They face both threats of punishment from the federal government for disregarding the wishes of immigration authorities, and legal challenges for heeding them.

After similar challenges were brought against municipalities for complying with detainer requests by the Obama administration, more than 350 police departments enacted policies to either disregard or more carefully scrutinize the requests of immigration authorities, according to Cecillia Wang, deputy director of the American Civil Liberties Union.

“Hundreds of jurisdictions have decided that they don’t unquestioningly comply with ICE detainers,” Ms. Wang said. “It buys them into lawsuits and forces them to violate people’s rights. And that is anathema to our system of constitutional liberties.”

Mr. Trump’s ability to follow through on his threat to punish sanctuary cities has been limited significantly. In April, it was temporarily blocked by a federal judge in San Francisco. Last month, Attorney General Jeff Sessions narrowed the threat in two regards, shrinking the definition of what constitutes a sanctuary city and the amount of money that could be taken away from one.

Urged by the White House, the House of Representatives passed a bill last week that could make it easier for Mr. Trump, and local authorities that honor detainers, to survive court challenges over the policy.

The legislation passed easily but is viewed as unlikely to pass the Senate. Even if it did, such a law could be stuck down if a court were to deem unconstitutional the practice of honoring detainers.

Mayor Giménez declined to comment on Wednesday, but a spokeswoman, Stephanie Severino, said that ICE had issued 376 detainers in Miami-Dade since the policy change and that of those, 143 inmates had been transferred into immigration custody. Others either remain in the county jail on criminal charges or were released after ICE decided not to pick them up.

Lawsuits against the use of ICE detainers have been brought before on behalf of United States citizens mistakenly caught up in the immigration enforcement system. Immigrant advocates say that such cases represent the worst that can happen when a higher standard of evidence is not required to hold a person in custody.

It was the second time Mr. Creedle, who is seeking financial damages from the county, was briefly suspected of being undocumented. Immigration authorities started a deportation case against him in 2015, then closed it after realizing that he was a citizen.