Sam Smith has stopped Madonna from topping the UK album chart, denying her the 12th number one of her career.

Madonna’s latest album, Rebel Heart, had been in pole position throughout the week, but Smith’s In The Lonely Hour sneaked ahead at the last minute. His record undoubtedly received a boost after he performed his new single, Lay Me Down, with John Legend on Friday night’s Comic Relief show.

In the end, he beat Madonna by 12,000 sales, the Official Chart Company said. In The Lonely Hour has now spent six separate spells at number one - a record for a male solo artist.

Only three other albums have done better - Simon and Garfunkel’s Bridge Over Troubled Water, which topped the charts on eight occasions; followed by Adele’s 21 and Emeli Sande’s Our Version Of Events, both of which managed seven.

Smith also topped the UK singles chart with Lay Me Down - the official Red Nose Day single - which achieved sales of 105,000. The album version of the song, which does not feature John Legend, also charted at number 18.

Rebel Heart is Madonna’s thirteenth studio album, and features collaborations with Kanye West, Nicki Minaj, Alicia Keys and Avicii.

Well-received by critics, it explores the star’s divorce from British film-maker Guy Ritchie, alongside her regular pet topics of dance and religion.

The last time one of Madonna’s studio albums failed to reach number one in the UK was 1994, when Bedtime Stories also made its debut at number two.

Elsewhere in the album chart, Rebecca Ferguson scored a new entry at number seven with Lady Sings The Blues, a collection of Billie Holiday covers.

Boyband Blue notched up their sixth top 20 album with Colours, which landed at 13; while Fleetwood Mac’s Greatest Hits notched up its 386th week in the top 100. Another Comic Relief performer, Ella Henderson, saw her album Chapter One leap 10 places, from 22 to 12.

Madonna’s greatest hits collection, Celebration, jumped from 38 to 27, but the highest climber was George Benson’s The Ultimate Collection, which rose 17 places to 37.

Top five singles

1) Sam Smith - Lay Me Down (ft John Legend)

2) Years & Years - King

3) Flo Rida - GDFR (ft Sage the Gemini)

4) Ellie Goulding - Love Me Like You Do

5) Rihanna, Kanye West and Paul McCartney