LOS ANGELES (AP) — Katy Perry, her collaborators and her record label must pay more than $2.78 million because the pop star’s 2013 hit “Dark Horse” copied a 2009 Christian rap song, a federal jury decided Thursday.

It was an underdog victory for rapper Marcus Gray, a relatively obscure artist once known as Flame, whose 5-year-old lawsuit survived constant court challenges and a trial against top-flight attorneys for Perry and the five other music-industry heavyweights who wrote her song.

The amount fell well short of the nearly $20 million sought by attorneys for Gray and the two co-writers of “Joyful Noise” — Emanuel Lambert and Chike Ojukwu — but they said they were pleased.

“We weren’t here seeking to punish anyone,” said Gray’s attorney, Michael A. Kahn. “Our clients came here seeking justice, and they feel they received justice from a jury of their peers.”

Perry herself was hit for just over $550,000, with Capitol Records responsible for the biggest part of the award — $1.2 million. Defense attorneys had argued for an overall award of about $360,000.

Perry’s attorney, Christine Lepera, said they plan to vigorously fight the decision.

“The writers of Dark Horse consider this a travesty of justice,” Lepera said.

“Dark Horse,” which combines elements of pop, hip-hop and trap styles, was a mega-hit for the Santa Barbara, California-born singer, with its call-and-response chorus of “Are you ready for (ready for), a perfect storm (perfect storm)?”

It spent four weeks at No. 1 on Billboard’s Hot 100 in early 2014, and Perry would later perform it at the Super Bowl.

Gray, a native of St. Louis, sued later in 2014. His song of earnest and ebullient praise stood in stark contrast to the playful black magic evoked by “Dark Horse,” and an early version of the lawsuit faulted Perry’s song for tainting the sanctity of his.

The two-week trial had two phases: One about music, one about money.

Perry took the witness stand on the first day of testimony. She testified, as her co-writers would, that she had never heard of Gray or Flame or “Joyful Noise” until he sued.

She got a rare laugh from the courtroom when her attorneys were struggling with technical issues as they tried to play a part of “Dark Horse.”

“I could perform it for you live,” said Perry, who did not appear in court for the rest of the trial.

The jury heard testimony from musicologists on the disputed section of the two songs — a piece of the musical backing track that plays during the verses of “Dark Horse” and throughout almost all of “Joyful Noise.”

While jurors were told to consider only those sections, they gave a surprisingly sweeping verdict Monday that held all six songwriters responsible for copying “Joyful Noise.” That included Perry, who wrote only lyrics, her co-lyricist Sarah Hudson, and Juicy J, who only provided a rap verse for the song.

The instrumental track that was most at issue was created by Dr. Luke, Max Martin and Circuit.

During closing arguments earlier Thursday, Gray’s attorneys said that because the relevant riff plays through 45 percent of “Dark Horse,” the plaintiffs should get 45 percent of its earnings, including every album that included it. They put those overall earnings at $41 million, thus seeking nearly $20 million.

The defense argued that only fractions of the album earnings should count for the single song and that considerable promotional expenses paid by Capitol Records should be subtracted.

Gray’s attorneys said those expenses were gratuitous, pointing out to jurors that they included $13,000 for a hairstylist for Perry for one awards show and nearly $2,000 for flashing cocktail ice cubes.

The nine jurors deliberated for two full days to reach their initial verdict but took just a few hours to decide on dollar amounts.

Perry’s five co-writers were each given penalties to pay that ranged from about $60,000 for Dr. Luke to more than $250,000 for Martin.

The jurors decided that the instrumental riff the two sides were fighting over was responsible for 22.5 percent of the success of “Dark Horse” and handed out the awards accordingly.

The defendants’ fight against the decision will begin immediately. U.S. District Judge Christina A. Snyder, who presided over the trial, will now consider a motion to throw out the case.

Lepera, Perry’s attorney, said outside court that the plaintiffs presented no evidence of copyright infringement, no evidence that the songwriters had access to “Joyful Noise” and no evidence the songs that were substantially similar.

“The only matter in common is an unprotectable C and a B note, repeated,” Lepera said. “We’ve been receiving outcry from people all over the world, including other musicologists.”

If the judge upholds the verdict, the case will almost certainly head to an appeals court, where jury awards in similar cases have often been changed or thrown out in recent years.

In the case of another 2013 mega-hit, “Blurred Lines,” a jury found singers Robin Thicke and Pharrell Williams copied R&B legend Marvin Gaye’s “Got to Give it Up” and ordered them to pay Gaye’s children nearly $7.4 million. The award was trimmed on appeal last year to just short of $5 million.

Kahn said he would be happy to keep up the battle.

“We think this is a fair and a just result, and we will defend it no matter how they fight it,” he said.