It's illegal for the police to hold you for a crime they know you didn't commit. Keeping you in custody in that situation is a violation of the Fourth Amendment, even if they bring you to court for your arraignment or initial appearance and the judge allows them to continue to hold you.
The U.S. Supreme Court made the above rule clear in the 2017 case Manuel v. City of Joliet. (137 S.Ct. 911 (2017).)
Some had argued that the Fourth Amendment, which prohibits unreasonable seizures of people and property, stopped applying once a defendant gets to court. But in Manuel, the Supreme Court established that detaining a defendant before trial without a valid reason—even after the defendant has had the chance to appear before a judge—will violate the Fourth Amendment.
In Manuel, the Court considered a lawsuit by a man held by the government for seven weeks on bad evidence. The police had found a bottle of pills after pulling over the man (Manuel). According to the lawsuit, the officers tested the pills on the spot; the test came back negative for any controlled substances. Nevertheless, they arrested Manuel and took him to the police station.
Manuel's lawsuit said that, at the station, an evidence technician retested the pills, again getting a negative result. But the technician stated in a report that the test indicated the pills were likely ecstasy. One of the officers also wrote in his report that he "knew the pills to be ecstasy." Using these statements, another officer swore out a complaint against Manuel for illegal drug possession.
The police soon brought Manuel in front of a judge. Relying on the complaint, which rested upon the allegedly false statements, the judge found that there was probable cause for the charge. That finding meant that the police could continue to hold Manuel. The judge sent Manuel to the county jail to wait for trial.
A different lab once again tested Manuel's pills. It issued a report that the pills didn't contain any controlled substances. The case nevertheless continued for another month, Manuel all the while lingering in jail. Finally, the prosecution dismissed the case—after Manuel had been held for 48 days.
Manuel later used a federal statute to sue the police for violating his civil rights. (42 U.S.C. §1983.) The first courts to consider the case ruled that he didn't have a claim under the Fourth Amendment because "lawful process" started when the judge found probable cause to hold him. In other words, to these courts, any Fourth Amendment problems essentially went away the moment that judicial oversight began.
The Supreme Court overruled the lower courts, saying essentially that a bad finding of probable cause really isn't a finding of probable cause. To the Court, the Fourth Amendment demands, even after court proceedings have started, that there be probable cause to hold someone.
The Manuel ruling didn't dramatically change existing law. Some lower courts had already interpreted the Fourth Amendment this way, and people who could show that they had been wrongly detained weren't necessarily out of luck even before the decision. Also, state law sometimes provides more protections than the U.S. Constitution and its amendments (including the Fourth). The Manuel case does, however, reinforce the Fourth Amendment as a powerful tool to challenge wrongful pretrial detention.