Image copyright AP/Getty Images Image caption Sam Smith said he was 'not previously familiar' with Tom Petty's track

Tom Petty has been given a songwriting credit on Sam Smith's hit Stay With Me, because of the similarities to his 1989 track I Won't Back Down.

Petty's publisher contacted Smith's team after it noticed a likeness between the two songs.

A spokesman for Smith said the singer "acknowledged the similarity", but the likeness was "a complete coincidence".

It was "amicably" agreed Petty and his collaborator Jeff Lynne would be credited as co-writers of the track.

Media playback is unsupported on your device Media caption Compare Sam Smith's Stay With Me to Tom Petty's I Won't Back Down.

Smith's spokesman said: "Recently the publishers for the song I Won't Back Down, written by Tom Petty and Jeff Lynne, contacted the publishers for Stay With Me, written by Sam Smith, James Napier and William Phillips, about similarities heard in the melodies of the choruses of the two compositions.

"Not previously familiar with the 1989 Petty/Lynne song, the writers of Stay With Me listened to I Won't Back Down and acknowledged the similarity.

"Although the likeness was a complete coincidence, all involved came to an immediate and amicable agreement."

Petty's I Won't Back Down peaked at number 12 in the US and number 28 in the UK in 1989, three years before Smith was born.

Image copyright ASCAP Image caption The American Society of Composers, Authors and Publishers now lists Petty and Lynne as co-writers

According to The Sun, an out-of-court settlement was made in October, but the details have only just emerged.

It is not clear whether Petty and Lynne will receive any royalties for the track.

A spokesman for Petty declined to comment to the BBC.

Stay With Me is nominated for three Grammys, including song of the year - which honours the writers of the track.

However, the Recording Academy said on Monday that Petty and Lynne would not be added to the nominations list for the song.

"Since Lynne and Petty did not do any new writing for this work, we are considering their original work to have been interpolated by Napier, Phillips and Smith for Stay With Me," it said.

It added that, should the song win, the pair would be given certificates to honour their participation in the work, in keeping with other writers whose music is sampled or interpolated in new compositions.