A New York federal judge has dismissed the rapper Drake’s defamation lawsuit against Universal Music Group over a Kendrick Lamar track that branded the Canadian singer a paedophile.

Judge Jeannette Vargas said the lyrics in Lamar’s Not Like Us, which refers to Drake as a “certified paedophile”, were a matter of opinion, which could not be “actionable defamation”.

The judgment ends a bitter legal fight during which Universal Music, the industry leader that commands about a third of the global market, found itself caught in the middle of rap’s “civil war”. Not Like Us was one of a series of so-called ‘diss’ tracks, used to verbally attack a rival, released in a battle between the two rappers that captivated listeners globally.

Why Are Drake and Kendrick Feuding? A Complete Timeline of the Rappers' Beef

Universal owns the separate record labels to which Drake and Lamar are signed, and profits from both artists’ work. Drake had accused Universal of promoting and monetising false and dangerous allegations. Universal argued the case should be thrown out because the lyrics were a matter of pure opinion, which cannot be the basis of a defamation claim in the US.

“The average listener is not under the impression that a diss track is the product of a thoughtful or disinterested investigation, conveying to the public fact-checked verifiable content,” judge Vargas wrote in the ruling.

She said Not Like Us was “replete with profanity, trash-talking, threats of violence, and figurative and hyperbolic language, all of which are indicia of opinion” and that it was “of particular relevance” that, in an earlier track, Drake had “challenged Lamar to make the paedophilia accusations”.

Kendrick Lamar's Latest Drake Troll Could Be His Best Ever | GQ

Lamar is tied to Universal-owned Interscope while Drake is distributed by another label it owns, Republic.

Drake, a Canadian rapper and one of Universal’s biggest stars, took aim at his own record label, turning what began as a rap feud into a courtroom battle.

“From the outset, this suit was an affront to all artists and their creative expression and never should have seen the light of day,” a Universal spokesperson said on Thursday.

The company added it “looked forward to continuing our work successfully promoting Drake’s music and investing in his career”.

Kendrick Lamar and Drake beef explained: What happens next? - Los Angeles  Times

In the judgment, Vargas described Not Like Us as a “cultural sensation” and said the lyrics accusing Drake of being a paedophile were “set to a catchy beat and propulsive bassline”.

The ruling quoted lyrics from the rap battle at length over several pages, including Lamar’s line: “Tryna strike a chord and it’s probably A-minor” and Drake’s response: “I never been with no one underage . . . If I was fucking young girls, I promise I’d have been arrested.”

Drake was the world’s second best-selling singer last year across physical sales, downloads and streaming, while Lamar ranked ninth, according to the International Federation of the Phonographic Industry.