The tip to the police was solid: An African-American man, in a striped shirt and a Yankees cap, was carrying a gun in a building in Upper Manhattan. Officers responded and made an arrest.

But where that information came from, and the lengths to which the police and law enforcement agents may have gone to conceal the source, turned a seemingly ordinary gun possession case into a flash point over legal ethics and a sharp dispute between a judge and federal prosecutors.

The judge, Alvin K. Hellerstein of Federal District Court in Manhattan, found that the arresting officers had created a “story to justify” the stop of the man and that federal agents endorsed falsehoods that were “contrived to protect” the identity of a supposedly anonymous source, who was actually a valuable confidential informant.

“A decision was made to coordinate among all the witnesses not to tell the full truth,” the judge said after he heard testimony from the arresting officers and from federal agents who helped to prepare a complaint against the man who was stopped, Tajuan Simmons, or who later testified before a grand jury.

Prosecutors in the office of Preet Bharara, the United States attorney in Manhattan, strongly defended the officers’ testimony as truthful and accurate; they asked the judge to withdraw his findings, citing the potential damage to the officers’ careers. The judge refused.

The use of confidential informants, or C.I.’s, is widely accepted in the criminal justice system. The Simmons case, as detailed in highly redacted court documents, offers a look at how the authorities protect such sources and what happened when a judge felt that they had gone too far.

The informant at the center of the dispute began working for the New York Police Department in January 2012 after he was arrested in a marijuana case, his “handler,” Sgt. Robert Nicholson, testified last fall at a suppression hearing requested by Mr. Simmons’s lawyers, who were seeking the exclusion of the gun as evidence.

Sergeant Nicholson said that the informant had been debriefed and had undergone a background check, and that he had agreed not to commit further crimes — a condition he violated when he was later arrested in a theft case.

But while he was active, the informant provided crucial information about shootings and narcotics and guns cases, the sergeant said.

The informant’s role was considered so sensitive that when Sergeant Nicholson testified, Judge Hellerstein closed the courtroom at the government’s request and even ordered that Mr. Simmons be removed from the proceeding. “I am convinced that if Simmons knew who the confidential informant was,” the judge said, the informant “would be at great danger.”

The sergeant testified that he received the informant’s call around 11 p.m. on April 17, 2012, and after hearing his information, told him to dial a police hot line that offers callers anonymity and financial compensation for information about illegal guns; a hot line detective then called the 911 operator.

Two days later, when the complaint was sworn before a magistrate judge, it omitted any mention of the informant and said merely that “an anonymous individual had placed a 911 call” with the information about Mr. Simmons. Sergeant Nicholson said he had taken this step to protect the source. Mr. Simmons, who had a robbery record, had been charged under a federal law that makes it illegal for a felon to possess a firearm.

Last fall, before the suppression hearing began, a prosecutor told the judge that the government had informed the defense about some recently discovered “misstatements” in the complaint. For one thing, the original caller had not been anonymous but was rather a known informant.

The complaint had also stated that Mr. Simmons, when he saw the police, immediately began to run to the north. “He did not run,” the prosecutor said.

Finally, Officer Matthew Barber, who had seized the gun and arrested Mr. Simmons, now recalled that he saw “a bulge” in Mr. Simmons’s waistband — a detail that had not been in the complaint.

At the hearing, a special agent with the Bureau of Alcohol, Tobacco, Firearms and Explosives, who had helped a prosecutor prepare the complaint, testified that he had omitted the informant’s role at the behest of either the prosecutor or another A.T.F. agent — he could not remember which one.

Photo

Alvin K. HellersteinCredit
Yana Paskova for The New York Times

Asked by the judge whether that was a practice of his office, the agent responded that if there was other evidence that established probable cause for an arrest, and “you do not have to risk the safety of an informant by exposing them, then you try to do that if possible.” (The identity of the agent is being withheld at the A.T.F.’s request because he remains involved in undercover work.)

Judge Hellerstein said the agent was “shading the truth” in not telling the magistrate judge about the informant.

The agent responded, “It’s a safety concern.”

The agent testified that the detail that Mr. Simmons had begun to run had come from one of the responding officers, Ramon Rolon. He quoted Officer Rolon as telling him, “Simmons fled in the other direction.”

“I give no credibility to Barber’s statement that he saw a bulge,” Judge Hellerstein said.

The judge even questioned whether the grand jury that indicted Mr. Simmons after hearing testimony from a Drug Enforcement Administration agent had received “accurate information.”

Judge Hellerstein found that to protect the informant, investigators had “created a different story to justify the stop” — namely, that Mr. Simmons had started to run away.

“That testimony was false,” the judge said. “Special agents were taken in with the story and implemented it knowing that it was less than truthful.”

He added, “A decision was made to tell perhaps the truth but not the whole truth.”

Judge Hellerstein said the observations of three officers were “not credible, not worthy of belief,” and added that if a confidential informant “is to be protected, there are ways to do it which do not require misstatements to a federal grand jury or a judge.”

Nonetheless, he ultimately refused to suppress the gun, finding that the informant’s tip had been accurate. Mr. Simmons pleaded guilty to a conspiracy count, and in March he was sentenced to five years in prison, the maximum.

His lawyer, Peggy Cross-Goldenberg, a federal public defender, said that despite her client’s conviction, the judge’s findings were important.

“If law enforcement purposely provides half-truths and contrived stories to conceal even the existence of a C.I.,” Ms. Cross-Goldenberg said, “there is no check on the reliability of confidential informants and no way for courts to determine whether the information provided was sufficient to justify the actions undertaken by law enforcement.”

Mr. Bharara’s office declined to comment. But in letters to the judge, prosecutors defended the officers’ accounts and said there was no evidence of collusion.

“Any confusion or lack of clarity about the underlying facts,” they wrote, “resulted from an entirely good faith but poorly executed attempt by this office, in drafting the complaint, to protect the existence and identity of a confidential source.”

They also argued that the officers, at the time of the arrest, were not aware of the informant, and that they thus had no motive to fabricate a story to protect him.

An A.T.F. spokesman, Charles J. Mulham, said, “The agency regrets that some of the facts in this investigation were articulated in a way that left the judge with concerns.”

“The special agents acted in complete good faith,” Mr. Mulham said, “with the purpose of pursuing appropriate law enforcement interests.”

J. David Goodman contributed reporting.

A version of this article appears in print on July 1, 2013, on Page A18 of the New York edition with the headline: Judge Says Police and U.S. Agents Misled Court in Manhattan Gun Possession Case. Order Reprints|Today's Paper|Subscribe