Perry's lawyers argued that subjecting simple musical elements to copyright would hurt music and all songwriters.

"They're trying to own basic building blocks of music, the alphabet of music that should be available to everyone," her lawyer Christine Lepera said.

Perry and the song's co-authors testified that they had never heard of Joyful Noise or knew Gray previously. They said they did not listen to Christian music.

But Gray's lawyers claimed that Joyful Noise was widely disseminated and could have been heard by Perry and her co-authors - as it has millions of plays on YouTube and Spotify, and was on an album nominated for a Grammy.

Michael Kahn, who represented Gray, told the court that Perry had started her career as a Christian artist, adding: "They're trying to shove Mr Gray into some gospel music alleyway that no one ever visits."

In a light hearted moment during the proceedings, the singer offered to perform her song live when efforts to play Dark Horse to the courtroom ran into trouble.

Dark Horse was the third single from Perry's 2013 album Prism. It spent four weeks at the top of the Billboard Hot 100 and earned her a Grammy nomination.

She also performed the song during her half-time show at the Super Bowl in 2015.