WASHINGTON  The sudden blow to the case against the former Blackwater security guards over a shooting that killed 17 Iraqis and wounded at least 20 may have come as a surprise to the public in Iraq and the United States, but the legal problem that the judge cited Thursday when he threw out the indictments was obvious to American government lawyers within days of the shooting.

The issue was that the guards, as government contractors, were obligated to give an immediate report of what they had done, but the Constitution prevents the government from requiring a defendant to testify against himself, so those statements could not be used in a prosecution.

Less than two weeks after the shootings in Nisour Square in Baghdad in September 2007, lawyers at the State Department, which employed the guards, expressed concern that prosecutors might be improperly using the compulsory reports in preparing a criminal case against them, according to the decision.

The prosecutors were also concerned, even using what they called a “taint team” to try to prevent information in the guards’ compulsory statements from influencing the investigation, according to the 90-page ruling by Judge Ricardo M. Urbina of Federal District Court in Washington. The judge said the prosecutors had failed to take “common sense precautions” to avoid the problem.