SAN FRANCISCO - A federal jury has sided with Google in a $9 billion legal battle with tech industry rival Oracle, a complex copyright case that was closely watched in Silicon Valley.

Oracle had said Google stole some of its Java software to create Android, the world's most popular smartphone operating system.

Some tech industry groups said Oracle's claim would undercut practices that are widely used to create all kinds of software.

Oracle had sought $9 billion in damages after saying Google, without Oracle's permission, copied certain elements of the Java programming language that helps different software programs talk to each other. Oracle said Google then reaped huge profits through ad sales on Google services like maps and search engines on Android phones and tablets.

But jurors found Google didn't need Oracle's permission to use certain elements of Java. The jury agreed with Google attorneys who argued that copyright law allows "fair use" of the Java elements because they were a small part of a much larger system of software that Google created for a new purpose.

The jury's verdict on Thursday marks Google's second victory in the case. U.S. District Judge William Alsup sided with Google in 2012, ruling that the Java elements — known in the industry as Application Programming Interfaces, or APIs — weren't protected by copyright. But an appellate court overturned Alsup's ruling and sent the case back for a second trial.

Oracle, which acquired the rights to Java when it bought Sun Microsystems in 2010, on Thursday immediately vowed to appeal.

"We strongly believe that Google developed Android by illegally copying core Java technology to rush into the mobile device market," said Oracle general counsel Dorian Daley in a statement. The company said "there are numerous grounds" for an appeal.

Google, a unit of the tech holding company Alphabet Inc., welcomed the jury's finding in its own statement.

"Today's verdict that Android makes fair use of Java APIs represents a win for the Android ecosystem, for the Java programming community, and for software developers who rely on open and free programming languages to build innovative consumer products," the company said.