In a “reckless violation of the defendants’ constitutional rights,” the judge wrote, investigators, prosecutors and government witnesses had inappropriately relied on statements that the guards had been compelled to make in debriefings by the State Department shortly after the shootings. The State Department had hired the guards to protect its officials.

News of the judgment came out late Thursday afternoon, when it was the middle of the night in Iraq.

Mark J. Hulkower, the defense lawyer for the lead defendant in the case, Paul A. Slough, who was manning a turret machine gun during the episode, said that his client and his family had gathered in Texas for New Year’s Eve when he called them to convey the news. They were “overjoyed,” he said.

“We are obviously pleased at the decision dismissing the entire indictment and are thrilled that these courageous young men can start the new year without this unfair cloud hanging over their heads,” Mr. Hulkower said.

The other defendants were Evan S. Liberty, Dustin L. Heard, Donald W. Ball and Nicholas A. Slatten. The Justice Department had earlier said it intended to drop manslaughter and weapons charges against Mr. Slatten.

Another Blackwater employee involved in the case, Jeremy P. Ridgeway, previously pleaded guilty to charges stemming from the shootings and was cooperating with prosecutors.

A Justice Department spokesman, Dean Boyd, said no decision had been made about whether to appeal the judge’s ruling.

“We’re still in the process of reviewing the opinion and considering our options,” Mr. Boyd said.

Advertisement Continue reading the main story

But Judge Urbina’s scathing and detailed review of the ways that crucial evidence and witnesses had been tainted by exposure to the defendants’ early statements — or to news media accounts based on them — appears likely to complicate any effort to ask an appeals court to overturn his opinion or to bring a new prosecution by a different legal team using any untainted evidence.

Daniel C. Richman, a former federal prosecutor who teaches criminal law at Columbia University, said that it was rare to have a judge issue a lengthy opinion at a pretrial stage. While cautioning that he had not read the opinion, he said that rulings like this one, consisting heavily of factual findings rather than merely legal interpretation, were “hard to challenge on appeal.”

The guards could not be prosecuted under Iraqi law because of an immunity agreement that had been signed by the Coalition Provisional Authority, the governing authority installed by the United States after the invasion of Iraq. But American prosecutors knew from the beginning that they were facing a difficult task in bringing the case. Complications included the applicability of federal statutes to the guards because they were working overseas at the time for the State Department, and the significant problem stemming from statements the guards gave shortly after the shootings.

Newsletter Sign Up Continue reading the main story Please verify you're not a robot by clicking the box. Invalid email address. Please re-enter. You must select a newsletter to subscribe to. Sign Up You will receive emails containing news content , updates and promotions from The New York Times. You may opt-out at any time. You agree to receive occasional updates and special offers for The New York Times's products and services. Thank you for subscribing. An error has occurred. Please try again later. View all New York Times newsletters.

The guards had been told by State Department investigators that they could be fired if they did not talk about the case, but that whatever they said would not be used against them in any criminal proceeding.

Nevertheless, Judge Urbina found that “in their zeal to bring charges,” investigators and prosecutors had extensively used those statements, disregarding “the warning of experienced, senior prosecutors” that “the course of action threatened the viability of prosecution.”

“The explanations offered by the prosecutors and investigators in an attempt to justify their actions and persuade the court that they did not use the defendants’ compelled testimony were all too often contradictory, unbelievable and lacking in credibility,” Judge Urbina wrote.

The judge also criticized prosecutors for withholding “substantial exculpatory evidence” from the grand jury that indicted the defendants, as well as for presenting “distorted versions” of witnesses’ testimony and improperly telling the grand jury that some incriminating statements had been made by the defendants but were being withheld.

The prosecutorial team was led by Kenneth C. Kohl, an assistant United States attorney. The Justice Department declined to make him available for comment.

The judge’s allegations of prosecutorial misconduct were the latest in several blows to federal prosecutors in 2009 in which judges dismissed high-profile cases.

Advertisement Continue reading the main story

Early in the year, for example, at the request of Attorney General Eric H. Holder Jr., a federal judge threw out the conviction of former Senator Ted Stevens, Republican of Alaska, for having failed to report gifts on his disclosure forms. Justice Department officials had uncovered evidence that prosecutors in that case had failed to turn over potentially exculpatory evidence to the defense, as required by law.

And last month, a federal judge threw out a major stock option back-dating case against top executives of the chip maker Broadcom Corporation after finding that a prosecutor in that case had inappropriately pressured witnesses to testify in a manner favorable to prosecutors.

In the Nisour Square shooting case, prosecutors did not charge Blackwater itself, but the families of several of the Iraqis who were killed have filed a civil lawsuit against the company, which has changed its name to Xe Services.

In addition, a grand jury in North Carolina, where Xe is based, is conducting a broad investigation into the company, which includes accusations of weapons smuggling and bribery of Iraqi officials in an attempt to ensure it would get approvals to continue operating in Iraq.

On Thursday, the president and chief executive officer of Xe, Joseph Yorio, praised Judge Urbina’s ruling in a statement.

“The company supports the judge’s decision to dismiss the charges,” he said. “From the beginning, Xe has stood behind the hundreds of brave men who put themselves in harm’s way to protect American diplomats working in Baghdad and other combat zones in Iraq. Like the people they were protecting, our Xe professionals were working for a free, safe and democratic Iraq for the Iraqi people.”

The mass shooting eventually led Iraq to insist, during negotiations on a new status of forces agreement in 2008, on a provision that eliminated immunity from Iraqi law for American contractors.