WASHINGTON — A federal judge late Friday ruled that the Trump administration’s mass firing of probationary employees this year was illegal, a victory for the labor unions and nonprofit groups that had sued the government over the terminations.

The ruling did not call on the government to return the fired probationary employees to their jobs, as would be the “ordinary course,” Judge William H. Alsup of the Northern District of California wrote in a 38-page opinion. Because the Supreme Court allowed the administration to continue its purge for months while the case proceeded, he said, “too much water has now passed under the bridge.”

Many of the fired probationary workers in the 17 agencies covered in the lawsuit have been reinstated to their posts, have found new jobs or do not want to return to their old jobs, Alsup said. And for some workers, agency reorganizations over the past few months have eliminated their positions.

Even so, the plaintiffs saw the ruling as a significant win.

— The New York Times