A federal appeals court ruled Friday that NASA should be blocked from conducting background checks on low-risk employees at its Jet Propulsion Laboratory, saying the practice threatens workers' constitutional rights.

The 9th U.S. Circuit Court of Appeals said the 28 scientists and engineers who refused to submit to the background checks "face a stark choice — either violation of their constitutional rights or loss of their jobs."

The decision written by Judge Kim Wardlaw reversed a ruling by U.S. District Judge Otis Wright and sent the case back to him with orders to issue an injunction on the workers' behalf.

• Click here to visit FOXNews.com's Space Center.

The workers sued the federal government, claiming that NASA was invading their privacy by requiring the investigations, which included probes into medical records and questioning of friends about everything from their finances to their sex lives.

If they didn't agree to the checks, they could be fired.

NASA has argued that requiring employees to submit to the investigations was not intrusive and that the directive followed a Bush administration policy applying to millions of civil servants and contractors.

The plaintiffs have worked for many years at JPL, which is known for its scientific explorations of space and study of Earth.

"We're ecstatic," workers' attorney Dan Stormer said. "This represents a vindication of constitutional protections that all of us are entitled to. It prevents the government from conducting needless searches into backgrounds."

If the workers were forced to quit rather than submit to invasive questions, it would hurt the space program, affecting Mars rover and other programs, Stormer said.

The higher court said Wright abused his discretion and committed several errors when he ruled that there was no merit to the claim that the scientists would suffer irreparable harm by signing the authorization forms.

It said that the lower court was wrong to conclude that the form which employees were asked to sign was "narrowly tailored."

"This form seeks highly personal information using an open-ended technique including asking for 'any adverse information which ... may have a bearing on this person's suitability for government employment,"' Wardlaw wrote. "There is nothing 'narrowly tailored' about such a broad inquisition."