Ed Sheeran has won his 'Shape of You' copyright trial.

The 31-year-old pop star was taken to court by grime artist Sami Chokri, who claimed that the melody of the 2017 smash hit is "strikingly similar" to that of his 2015 song 'Oh Why', but a judge ruled on Wednesday that Ed and his collaborators, Johnny McDaid and Steven McCutcheon, had not plagiarised the earlier hit.

Judge Antony Zacaroli acknowledged there were "similarities between the one-bar phrase" in 'Shape of You' and 'Oh Why' but said "such similarities are only a starting point for a possible infringement" of copyright.

After studying the musical elements, he found there were " differences between the relevant parts" of the songs, which "provide compelling evidence that the 'Oh I' phrase" in Ed's song "originated from sources other than Oh Why", and so declared the 'Castle on the Hill' hitmaker had "neither deliberately nor subconsciously copied" the track.

The judge noted there was only a "speculative foundation" for the defence's argument Ed had heard the 2015 song before writing his.

He added: "I find, as a matter of fact, that he had not heard it."

After the verdict was delivered, Ed, Johnny and Steven – who is known as Steve Mac – said they were "grateful" for the ruling but admitted having to prove themselves and their integrity had been "painful".

They said in a joint statement: "There is an impact on both us and the wider circle of songwriters everywhere. Our hope in having gone through all of this, is that it shows that there is a need for a safe space for all songwriters to be creative, and free to express their hearts. That is why we all got into this in the first place. Everyone should be able to freely express themselves in music, in art and do so fearlessly.

"At the same time, we believe that there should be due process for legitimate and warranted copyright protection. However, that is not the same as having a culture where unwarranted claims are easily brought. This is not constructive or conducive to a culture of creativity.

"We are grateful that Mr. Justice Zacaroli has delivered a clear and considered judgment which supports the position we have argued from the outset. ‘Shape of You’ is original. We did not copy the Defendants’ song.

"We respect the music of those who’ve come before us and have inspired us along the way, whoever they are. We have always sought to clear or to acknowledge our influences and collaborators. It doesn’t matter how successful something appears to be, we still respect it.

"It is so painful to hear someone publicly, and aggressively, challenge your integrity.

"It is so painful to have to defend yourself against accusations that you have done something that you haven’t done and would never do.

"We are very grateful for all the messages of love, hope and support we received throughout the course of this case from songwriters everywhere. Thank you also to our publishers, who stood shoulder to shoulder with us at every step of the way. We are privileged to do what we do, and we know that. We want to live in a world where we are free to do what we do, openly and honorably.

"While this has been one of the most difficult things we have ever been through in our professional lives, we will continue to stand up against baseless claims, and protect our rights and the integrity of our musical creativity, so we that can continue to make music, always.

"Our message to songwriters everywhere is: Please support each other. Be kind to one another. Let’s continue to cultivate a spirit of community and creativity."

And the trio admitted the court battle had taken a toll on their mental health and creativity.

They said: "There was a lot of talk throughout this case about cost. But there is more than just a financial cost.

"There is a cost on creativity. When we are tangled up in law suits, we are not making music or playing shows.

"There is a cost on our mental health. The stress this causes on all sides is immense. It affects so many aspects of our everyday lives and the lives of our families and friends.

"We are not corporations. We are not entities. We are human beings. We are songwriters. We do not want to diminish the hurt and pain anyone has suffered through this, and at the same time, we feel it is important to acknowledge that we too have had our own hurts and life struggles throughout the course of this process."