Oracle sued Google in 2010 over its copying of application programming interfaces from Oracle’s Java SE for the Android mobile operating system, demanding billions in damages.
But the court sided with Google in a 6-2 decision, saying the copying was an example of fair use.
The ruling affirms a longstanding practice in software development.
But the court declined to give an opinion on the wider question of whether APIs are copyrightable.
Google said the decision was a victory for “consumers, interoperability, and computer science”.
“The decision gives legal certainty to the next generation of developers whose new products and services will benefit consumers,” the company said.
Oracle reiterated its allegation that Google “stole” Java and enforced its actions using its economic dominance.
“This behaviour is exactly why regulatory authorities around the world and in the United States are examining Google’s business practices,” Oracle said in a statement.
Justice Stephen Breyer, in his written opinion, said it was difficult to apply traditional copyright concepts in the world of software programming, but noted that Google copied “only what was needed” in Android.
He argued that allowing Oracle to enforce its copyright claim would “risk harm to the public” by turning computer code into a “lock limiting the future creativity of new programs”.
“Oracle alone would hold the key,” Breyer wrote, adding that such a situation would “interfere with, not further, copyright’s basic creativity objectives”.
In his dissenting opinion, Justice Clarence Thomas wrote that such an interpretation effectively “eviscerates copyright”.
He argued that the majority opinion was fundamentally contradictory, since it affirmed that code is copyrightable while holding to a fair-use analysis.
“Oracle’s code at issue here is copyrightable, and Google’s use of that copyrighted code was anything but fair,” he wrote.
Google had argued that an Oracle win would force developers to reinvent the wheel every time they wanted to instruct a computer to carry out a basic task, or else pay enormous copyright fees.
Oracle said the ability of programmers to be rewarded for their work was at stake, and had demanded $9 billion (£6bn) from Google.
Industry watchers said that the court’s decision not to rule directly on the copyrightability of APIs could invite future similar lawsuits.
Trolls beware. Twitter releases feature that will deliver a 'reconsider prompt' for users, if they…