A federal judge in Washington State has dismissed a lawsuit that accused a civilian intelligence analyst working for the military of breaking the law by using a fake name to infiltrate antiwar groups and trying to thwart protests by sharing information he collected with the Army, law enforcement agencies and private security firms.

Plaintiffs in the case, which was filed in 2010, contended that the actions of the analyst, John J. Towery, had deterred their free speech and led to their arrests, violating First and Fourth Amendment rights as well as statutes forbidding military surveillance of civilian groups.

The judge, Ronald B. Leighton of Federal District Court in Tacoma, did not issue a written opinion to accompany an order issued on Wednesday that granted summary judgment motions filed on behalf of Mr. Towery, his former supervisor at Joint Base Lewis-McChord, Thomas Rudd, and several police officials.

Mr. Towery’s motion did not deny that he had infiltrated groups using the name John Jacob, but it stated that his actions did not break the law. The covert scrutiny was warranted, the motion said, because it was intended to keep track of criminal behavior associated with protests, which sometimes became confrontational and turbulent, and because Mr. Towery had not intended to chill free speech. The plaintiffs lacked evidence that he had been spurred by a desire to curb expressive activities, the motion added.