Palantir, a data mining behemoth that received startup funding from the CIA, just got its foot in the door to a lucrative U.S. military contract following a months-long legal battle with the Army.

On Monday the software company won the chance to pitch its data services, the Gotham Platform, to help build out an upgrade to the Distributed Common Ground System — an Army program “that gathers intelligence spanning all echelons from space to mud,” according to the service’s website.

The contracts for the project could eventually total in the billions of dollars.

The Army has had a strained relationship with the Silicon Valley startup, despite the company’s coziness with the intelligence community, according to press reports. This summer, Palantir sued the Army, alleging it failed to abide by solicitation rules when it excluded the company from the bid to help design the intelligence system.

The Army asserted Palantir couldn’t sue before the contract was awarded, and didn’t have standing to do so.

U.S. Court of Federal Claims Judge Marian Blank Horn agreed with Palantir during an open hearing on Monday, according to Bloomberg News. Her written opinion was filed under seal, giving both parties a chance to request redactions.

Once called “the war on terror’s secret weapon,” Palantir’s software helps users, whether law enforcement officials or businesspeople, understand and track relationships in data. The company’s proprietary algorithms are designed to sift through massive troves of data — whether bank transactions, social media interactions, weather calculations, or crime reports — and spit out conclusions about everything from terrorist cells to car thieves.

Palantir is in part the brainchild of Peter Thiel, the controversial Silicon Valley mogul and now vocal Donald Trump supporter, who bankrolled a legal battle that pushed Gawker into bankruptcy. According to an interview with The New York Times, Thiel with several partners started the company, which he named after a Lord of the Rings artifact, to protect national security in the wake of the September 11 attacks. The company received startup funding from In-Q-Tel, the CIA-funded venture capital firm.

Groups like the American Civil Liberties Union have argued Palantir’s software enables mass surveillance.

Palantir’s court battle with the Army comes at a time when Secretary of Defense Ashton Carter has expressed enthusiasm for building a closer relationship with tech companies on the West Coast. He recently launched the Defense Innovation Unit Experimental, with outposts in Silicon Valley and Boston.

The Army and Palantir did not respond immediately to a request for comment.