Image caption Coldplay's show was full of gestures to other bands and the Glastonbury spirit

Coldplay have given Glastonbury's grand finale, with a little help from the Bee Gees.

Barry Gibb joined the band for two Bee Gee covers: To Love Somebody and what Chris Martin called "the greatest song of all time", Stayin' Alive.

Gibb was meant to play Glastonbury's "legend" slot this year, but pulled out when a family member fell ill.

The Bee Gee tribute came towards the end of a multicoloured, carnivalesque set that defied the pouring rain.

Bathed in colour, the band took the stage at 21:30, launching into A Head Full Of Dreams, accompanied by fireworks and rainbow glitter cannons.

"This is our favourite place in the world!" declared Chris Martin as he played the opening chords to Yellow.

Image copyright Getty Images Image caption This is the band's fourth time headlining Glastonbury

Image caption The Bee Gees never played Glastonbury before the death of Barry's brothers Maurice and Robin

The band now hold the record for headlining Glastonbury, having topped the bill on four occasions - 2002, 2005, 2011 and 2016.

They worked hard to make Sunday's set an inclusive, celebratory end to the festival - Martin dedicated the show to the fans who had been "through the rain, and the mud, and the carnage" of the festival; and later invited organiser Michael Eavis on stage for a wobbly rendition of My Way (in the key of D).

Every song sounded like an encore - from the pounding beats of Clocks, to the anthemic Fix You.

And the band gave the entire audience the sense they were participants in a Glastonbury headline set by distributing 100,000 multi-coloured LED wristbands, which pulsed in time to the music, lighting up Worthy Farm as far as the eye could see.

Coldplay even found time for a cover of Boys That Sing by Viola Beach - an up-and-coming band who tragically died in a car accident earlier this year.

"We decided to create Viola Beach's alternate reality and let them headline Glastonbury for a song," said Martin, to a huge round of applause.

Footage of the young band playing the song was shown on video screens during the performance, in what was a risky, but poignant, moment.

Manchester indie band Blossoms, who were friends with Viola Beach, told the BBC they appreciated the gesture.

"I think it's important that a big band does something like that at such a big festival," said singer Tom Ogen, "because you want their music to live on and be remembered fondly."

'State of the world'

Immediately prior to Coldplay's appearance, the band played Charlie Chaplin's speech from The Great Dictator - a 1940 political satire denouncing Hitler, Mussolini, fascism and anti-Semitism.

"The Kingdom of God is within man - not one man nor a group of men, but in all men! In you! You, the people have the power - the power to create machines. The power to create happiness! You, the people, have the power to make this life free and beautiful, to make this life a wonderful adventure."

Martin had previously said the show may address last week's Leave vote.

After the second song of the night, Yellow, he said: "We came here a little bit scared about the state of the world, but just seeing the vibe at Glastonbury makes me think people are great and together we can do wonderful, wonderful things.

"Thank you for restoring my faith in the world."

Image copyright Reuters Image caption The band shot dove-shaped confetti into the crowd during the song Every Teardrop

Earlier on The Other Stage, PJ Harvey opened her set in a similar way, reciting John Donne's Meditation XVII, which begins: "No man is an island."

She joined the likes of Damon Albarn, The 1975, Novelist and Paul Heaton in protesting at the decision over the weekend

Travel advice

Coldplay were preceded on the Pyramid Stage by US star Beck, who played an eclectic, career-spanning set that also wove in tributes to David Bowie (China Girl) and Prince (1999).

Like many of today's acts, he had to battle against the elements - as exhausted, mud-soaked revellers suffered yet more rain.

"It's a little bit miserable out right now, isn't it?" he asked at one point. "Thank you for making the most of it, though."

Image copyright AP Image caption Beck also included sections of Strawberry Fields Forever in his song Where It's At

Image copyright AP Image caption LCD Soundsystem provided a hard-hitting dance alternative to Coldplay on The Other Stage

Image copyright Reuters Image caption Canadian alt-pop star Grimes was the headliner on the Park Stage

Ellie Goulding, Laura Mvula and Gregory Porter also played the main stage, while Jeff Lynne's ELO took the coveted "legends slot" - following in the footsteps of Dolly Parton and Lionel Richie.

His set soundtracked one of the festival's more surreal moments - as a fan crowdsurfed from inside a dinghy.

LCD Soundsystem gave clubbers the chance for one last dance in the mud in a headline set at the Other Stage, while funk legends Earth, Wind & Fire attracted a family crowd to the West Holts stage.

Meanwhile, revellers leaving Glastonbury have been told they may need to be towed out of the festival's car parks, after a week of wet weather turned the car parks into quagmires.

Advice published on the official website states: "There are likely to be some delays leaving the site. Go to the toilet before you set off. Have drinks, snacks and any essential medication with you.

"And if your vehicle has a towing eye, please attach this ready for possible towing."