Donald Trump supporter and Silicon Valley maverick Peter Thiel won a battle with the Obama administration on Monday when a federal judge ruled that the Army improperly excluded his computer data system from consideration for a new multimillion-dollar contract.

Mr. Thiel, one of the few conservative titans in the liberal world of Facebook and Google, founded Palantir Technologies a decade ago. It has been in a long struggle to persuade the Army to integrate its intelligence management network into the service’s Distributed Common Ground System.

Last year the Army wrote requirements for a new version in such a way that Palantir’s intelligence software was locked out. The firm filed suit last summer in the U.S. Court of Federal Claims.

In unsealed court documents, Palantir’s attorneys showed the Gotham system of collecting and disseminating intelligence could be integrated easily into the common ground system, while Army witnesses said it could not.

Judge Marian Blank Horn sided Monday with Palantir by ordering the Army to stop its current acquisition plan. Her injunction said the Army must develop a new solicitation that involves extensive market research into commercially available systems, such as Palantir.

Hamish Hume, Palantir’s lawyer, argued that the Army did not follow a 1994 federal law that requires the Pentagon to buy less expensive commercial systems in order to avoid the more costly process of researching, developing and procuring the military’s own components. The statute also directs agencies to conduct thorough market research to find products — the part of the law that Judge Horn is ordering the Army to meet.

“The first reason is it saves money,” Mr. Hume told reporters on a conference call after the ruling. “If a product has already been [through] development, it’s less expensive to buy that product than for the government to go out and try to reinvent it or redevelop it from scratch. … It takes time. A massive amount of time.”

He called the ruling a “landmark” case because government buyers have generally ignored the 1994 law.

Mr. Thiel, a venture capitalist and hedge fund manager, is one of the few Silicon Valley leaders to publicly endorse Mr. Trump, the Republican presidential nominee, over Democrat Hillary Clinton. He spoke in prime time at the GOP convention and recently wrote a $1 million-plus check to fund the Trump effort. The billionaire was an early investor in Facebook and also founded PayPal.

The liberal website Slate, meanwhile, has called for Silicon Valley to “excommunicate” Mr. Thiel.

In September the Obama administration, through the Labor Department, sued Palantir, alleging the Palo Alto, California, company discriminates against Asian job applicants. Palantir denied the charge, and conservatives wondered if the action was retaliation for Mr. Thiel’s politics.

Army soldiers have said in leaked memos from the Afghanistan war zone that they love Palantir’s effectiveness and speed in analyzing the enemy. The Army often blocked or delayed permission to buy the system off the shelf. Some of those same soldiers complained that the common ground system was too slow and prone to crashes.

Judge Horn told Army lawyers they must make a sincere effort to follow the 1994 statue. Mr. Hume, of the law firm Boies, Schiller & Flexner, said that government lawyers made remarks to the judge that indicated the Army planned few changes in its solicitation to industry.

Rep. Duncan Hunter, California Republican and a former Marine Corps officer, had led the fight in Congress to expose flaws in the Distributed Common Ground System (DCGS).

“It’s about time this happened, but it’s still amazing that it took a court of law to reveal the truth about DCGS and counter the blatant misrepresentations and falsehoods that originated within a bureaucracy that is supposed to look out for the best interests of our soldiers,” Mr. Hunter said. “Instead, our troops have been put at a disadvantage, all while taxpayers have been asked to give even more money — above the billions of dollars allocated so far — for the next installment of DCGS.

“From the start, this was always more than just a contracting fight. Soldiers in combat have repeatedly requested an off-the-shelf alternative that they assert saves lives. In one instance, a commander of a major division called it a matter of life and limb. The fact that this technology has been repeatedly denied and actively discredited is an example of bureaucracy at its worst,” he said.

Sen. Tom Cotton, Arkansas Republican and a former Army infantry officer who fought in Iraq and Afghanistan, said: “I applaud the Court of Federal Claims for forcing the Army to look at a true commercial solution to the long-troubled DCGS-A program. The Army’s modernization budget is too small and has too many other priorities to continue to waste precious modernization dollars on developing a program from scratch when a viable commercial alternative already exists.”

Congressional aides say that Gen. Mark Milley, the new Army chief of staff, appears more willing to buy off-the-shelf technologies.