Ed Sheeran has reached a deal to end a lawsuit for $20m (£13.8m) over his song “Photograph”, which was alleged to have been “copied” from a single released by X Factor winner Matt Cardle.

Sheeran was accused of “note-for-note” copying from the song “Amazing”, which was released by Cardle five years ago.

Thomas Leonard and Martin Harrington, who wrote the song, sued Sheeran and claimed he was “unabashedly taking credit” for their work.

In a complaint lodged in the US in July, they said: “This copying is, in many instances, verbatim, note-for-note copying, makes up nearly one half of ‘Photograph’, and raises this case to the unusual level of strikingly similar copying.”

The pair submitted the chord structures for both tracks and claimed the two songs shared 39 identical notes, with similarities they said were “instantly recognisable to the ordinary observer”.

They were represented by Richard Busch, the lawyer who successfully worked for Marvin Gaye’s family over the “Blurred Lines” copyright infringement case that won a $7.4m settlement from Robin Thicke and Pharrell Williams.

Details of the settlement were not revealed in court papers, however an order signed by judge James Selna at a California court this week said that the case has been dismissed, after an agreement was reached between the parties.

Mr Busch told Sky News: “I can confirm the case has settled but cannot comment further.”

“Photograph” was released from Sheeran’s album x [multiply], and reached number 15 in the UK singles chart and number 10 on the US Billboard Hot 100.