Image copyright Getty Images Image caption The star last played Glastonbury's Pyramid Stage in 2004

One of the worst-kept secrets in pop has been confirmed: Sir Paul McCartney will headline Glastonbury in 2020.

The former Beatle will top the bill on the Pyramid Stage on Saturday 27 June, a week after his 78th birthday.

He last played the Somerset event in 2004, and organisers have long been keen to get him back for an encore.

Next year will be Glastonbury's golden jubilee and co-organiser Emily Eavis said: "There really was no-one that we wanted more for the 50th anniversary."

Earlier on Monday, the star teased the announcement on Twitter - posting a picture of Philip Glass, Emma Stone and Chuck Berry.

Emily Eavis subsequently confirmed the news, saying: "Having Paul McCartney coming back to headline the Pyramid for the second time next year is an absolute dream come true."

In April, her father, festival founder Michael Eavis, admitted he had the star in his sights, but asked a BBC reporter not to "make a big thing of it".

In September, Sir Paul told BBC Radio 2 the booking "was starting to become [a] remote kind of possibility".

He told breakfast host Zoe Ball: "My kids are saying, 'Dad, we've got to talk about Glastonbury', and I think I know what they mean.

"We played there quite a long time ago so maybe it is time to go back. I don't know. I'd have to put a few things in place."

'They'll never top this'

The rock legend's last appearance on the Pyramid Stage came after a day of heavy rain that left fans soaked to the skin.

But his arrival was greeted with an almighty cheer, and he responded with a joyous, two-and-a-half hour greatest hits set - opening with Wings classic Jet and racing through 22 Beatles songs, including Helter Skelter, Back In The USSR and Yesterday.

"Spare a thought for Michael Eavis. He could live to host a hundred more Glastos and he'd never top this," wrote the NME in its review.

"And pity us poor punters, oblivious to the fact we are sinking in mud and soaked to the skin, because every gig we go to from now will fall short of this."

Image copyright PA Media Image caption The gig later won an NME Award for musical event of the year

Incredibly, after playing more than 3,000 concerts, Glastonbury was the star's first ever festival set. He later recalled looking out over the the flags, banners and bedraggled fans and thinking it looked "like the Battle of Agincourt".

He closed the show with The End, the final song on The Beatles' Abbey Road album. But it was the all-together-now chorus of Hey Jude that made a lasting impression, echoing around Worthy Farm until the early hours of Sunday morning.

"Paul won the day for me," said Michael Eavis after the concert. "He hugged and kissed me afterwards but I should have kissed him."

Sir Paul later told Clash magazine: "It was a good night for us. It was a blast, and the audience seemed to love it. It was like, 'Yeah man! People have come together!' Very uplifting."

Media playback is unsupported on your device Media caption Paul McCartney chats about fame, flirtation and "mad captain" Donald Trump.

The star is the first headliner to be confirmed for Glastonbury 2020. Diana Ross will play the Sunday afternoon "legends slot", while other rumoured headliners include Taylor Swift, Kendrick Lamar, The 1975 and Foals.

Fleetwood Mac, who have long been linked with the festival, also prompted speculation that they would be heading to Somerset next year when Mick Fleetwood told fans at Wembley Stadium they still "had a big field to play".

But speaking at the Cheltenham Literature Festival last month, Emily Eavis ruled the band out after negotiations apparently stalled over money.

"I can't afford them at the moment," Michael told fans in June. "But they said the other day that they really want to do it and if they don't do it before they die they'll go to hell."

Follow us on Facebook, or on Twitter @BBCNewsEnts. If you have a story suggestion email entertainment.news@bbc.co.uk.