Katy Perry, Capitol Records and the producer Dr Luke have been ordered to pay $2.78m (£2.3m) in damages to a Christian rapper after a jury in California found that her song Dark Horse plagiarised one of his tracks.

Marcus Gray, who records as Flame, and co-writers of his 2008 track Joyful Noise, Emanuel Lambert and Chike Ojukwu, sued Perry and five other producers and songwriters who worked on Dark Horse. Among those sued include Dr Luke and Max Martin, and rapper Juicy J.

In the damages phase of the trial on Tuesday, jurors learned that Dark Horse had made around $41m in total, earning Perry just over $3m with the rest going to Capitaol Records. The jury decided to award Gray and his co-plaintiffs $2.78m, with just over half a million dollars to be paid by Perry and the rest by Capital.

Gray’s lawyers argued that the beat of Dark Horse had been copied from Joyful Noise, but Perry and her co-writers claimed they had never heard the track, and were not aware of Gray. But Gray’s lawyer successfully argued that Joyful Noise was a widely known song, pointing to its millions of plays on YouTube and Spotify. “They’re trying to shove Mr Gray into some gospel music alleyway that no one ever visits,” argued Michael A Kahn.

Perry’s lawyer, Christine Lepera, countered by saying Gray and his team were “trying to own basic building blocks of music, the alphabet of music that should be available to everyone”.

Gray’s lawsuit was filed in 2014, the year after the release of Dark Horse, which became one of Katy Perry’s biggest hits. It was her ninth US No 1 single, was nominated for a Grammy award and became the second-biggest-selling single worldwide in 2014. Its video has been viewed 2.6bn times on YouTube.

Although the case focused solely on the beat of Dark Horse, all six of its songwriters were judged to have infringed copyright, including lyricists Sarah Hudson and Juicy J, and all owe damages.

Perry testified during the case, and offered to perform Dark Horse in person during technical difficulties with playback of the song.

A motion from Perry’s lawyers asking for a rule that no reasonable jury could find copyright infringement based on the evidence presented is still pending. If the judge sides with Perry, the damages award will be void.