The Supreme Court ruled Monday in favor of Google in a long-running copyright dispute against Oracle that has huge implications for Silicon Valley — with the court finding that Google did not violate the law when it used more than 11,000 lines of Oracle’s software code in developing its Android mobile operating system.

The U.S. tech industry has been deeply invested in the outcome of the case because it will shape the country’s rules around building software, the process upon which the multi-trillion-dollar sector rests. It also gives Google a key win at a time when scrutiny of the search giant has hit a fever pitch in Washington, including a Justice Department antitrust suit against Google and and questions over whether Obama-era federal regulators erred by not taking action against the search giant in an earlier antitrust investigation.

Monday’s 6-2 decision is a key ruling on how U.S. copyright applies to API, software code that enables programs to work with each other. In the case, which dates back to 2010, Google had stood accused of pilfering chunks of API code developed by Sun Microsystems, which was later acquired by Oracle.

“We assume, for argument’s sake, that the material was copyrightable,” the decision said. “But we hold that the copying here at issue nonetheless constituted a fair use. Hence, Google’s copying did not violate the copyright law."

Google had argued that this type of code is often used freely by developers to increase interoperability between different products, and that even if such code is copyrightable — as Oracle had argued — it should be covered by the law’s “fair use" provisions, which allow the unlicensed use of otherwise copyrighted material under some circumstances.

Oracle had argued that the code was copyrightable, that it should have been paid for Google’s use of it and that while some standard code is exempt from the protections, the Java code was anything but standard.

Each side in the case claimed that it was, here, the true champion of innovation. Google argued that applying stringent copyright protections to APIs would chill developers who would otherwise build using shared code. That, the company said, would bad for developers, slowing the process of creating new products, and bad for consumers, minimizing the utility of products they already own. Oracle had argued that a Google victory would discourage programmers from investing deeply in software developing, knowing that the resulting code could be used by others without compensation.

The Supreme Court said Google’s use of the Java API “included only those lines of code that were needed to allow programmers to put their accrued talents to work in a new and transformative program.” Justice Stephen Breyer, who wrote the majority opinion in favor of Google, was joined by Sonia Sotomayor, Elena Kagan, Neil Gorsuch and Brett Kavanaugh. Justices Clarence Thomas and Samuel Alito dissented.

Kent Walker, Google’s senior vice president of global affairs, described the ruling as a victory for innovation. “The decision gives legal certainty to the next generation of developers whose new products and services will benefit consumers,” he said.

Google and Oracle are fierce political adversaries, with each side arguing that the other plays unfair not simply in business, but in the tech policy debates that have gripped Washington in recent years. Those range from antitrust to privacy to how much latitude online platforms should have in policing user posts on their sites. Google’s victory in the case could provide it — and its allies — with political momentum as it wages those larger policy battles in the months and years to come.