Katy Perry won an appeal in her long-running Dark Horse copyright case on Thursday.

According to Variety, Perry was defending the claim that her 2013 song Dark Horse infringed on the copyright of rapper Marcus Gray, also known by his stage name Flame.

Gray claimed that Perry's song infringed on his copyright as it was substantially similar to his song Joyful Noise.

The rapper first sued in 2014, and a Los Angeles jury found Perry liable for infringement in 2019.

The verdict was overturned a year later when a judge ruled that the eight-note ostinato - a continually repeated musical phrase or rhythm - Perry allegedly copied lacked the "quantum of originality" to warrant copyright protection. Gray appealed the decision in October 2020, arguing the similarity of each song's timbre.

The U.S. Court of Appeals for the Ninth Circuit upheld that decision on Thursday, ruling that a decision against Perry would have dangerous consequences for future creativity.

"The portion of the Joyful Noise ostinato that overlaps with the Dark Horse ostinato consists of a manifestly conventional arrangement of musical building blocks," the appeals court wrote in their ruling, reports Billboard. "Allowing a copyright over this material would essentially amount to allowing an improper monopoly over two-note pitch sequences or even the minor scale itself."

Unless Gray takes the case to the U.S. Supreme Court, the ruling marks the end of the road for the long-running legal action.