The US Supreme Court on Monday ruled that Google can legally use Oracle’s  Java programming language for building Android mobile operating system, saying it was a “fair use.” 

In a 6-2 opinion, the court said, “Google’s copying of the API to reimpliment a user interface, taking only what was needed to allow users to put their accrued talents to work in a new and transformative program, constituted a fair use of that material.”

The ruling overturned a previous decision by the court. The earlier ruling had said that the use of Oracle’s API by Google constitutes “infringement.”

Monday’s ruling will save Google from paying out billions to Oracle.

The case revolved around whether copyright protection should be extended to application software interfaces (APIs), the bits of code that allow programs and apps to work together, and if so, whether Google’s implementation of Oracle’s API  was a “fair use” of copyrighted material.

The case drew interest across the spectrum of technology firms and creative industries, and heated debate on how much copyright protection should be afforded to bits of computer code.

Two separate jury trials ended with a determination that Google’s “software interface” did not unfairly use Java code, saving the internet giant from a possible multibillion-dollar verdict.