Human genes may not be patented, but artificially copied DNA can be claimed as intellectual property, the US Supreme Court has ruled unanimously.
The court quashed patents held by a Utah-based firm on two genes linked to breast and ovarian cancer.
The opinion said DNA came from nature and was not eligible for patenting.
The US biotechnology industry had warned any blanket ban on such patents would jeopardise huge investment in gene research and therapies.
"We hold that a naturally occurring DNA segment is a product of nature and not patent eligible merely because it has been isolated," Justice Clarence Thomas wrote in Thursday's opinion.
But his ruling said that synthetic molecules known as complementary DNA can be patented "because it is not naturally occurring".
'Different chemical structure'
Myriad Genetics, the company at the heart of the lawsuit, saw its shares rise after Thursday's compromise decision.
The legal battle was prompted by a lawsuit from the American Civil Liberties Union (ACLU) in 2009 that centred on whether companies should be able to patent genes.
Currently, researchers and private companies work to isolate genes in order to use them in tests for gene-related illnesses, and in emerging gene therapies.
The genes at the centre of the lawsuit are linked to breast and ovarian cancer. Myriad Genetics developed a pioneering test to look for mutations in those genes that might increase the risk of developing cancer.
Myriad, based in Salt Lake City, argued that the genes in question had been "isolated" by the company, making them products of human ingenuity and therefore patentable.
But the ACLU argued that genes are products of nature, and therefore cannot be patented under US laws.
In 2010 a New York federal court ruled in favour of the ACLU.
But an appeals court on two separate occasions sided with Myriad. It said DNA isolated from the human body had a "markedly different chemical structure" from other human genetic material.
Thursday's Supreme Court ruling largely sided with the ACLU.
"Genes and the information they encode are not patent eligible... simply because they have been isolated from the surrounding genetic material," Justice Thomas wrote.
In a concurring opinion, Justice Antonin Scalia wrote "the portion of the DNA isolated from its natural state sought to be patented is identical to that portion of the DNA in its natural state".
Sandra Park, a lawyer for the ACLU, welcomed the decision.
"Because of this ruling, patients will have greater access to genetic testing and scientists can engage in research on these genes without fear of being sued," she said.
Universities and medical research firms have been able to claim intellectual property over human genes for nearly three decades.
According to researchers at Weill Cornell Medical College in the US, patents now cover some 40% of the human genome.