The singer-songwriter, who turned 80 a week ago, was the oldest ever solo headliner at Worthy Farm in south-west England, where the festival celebrated its fiftieth anniversary two years later than planned due to the pandemic.
Opening with "Can't Buy Me Love", McCartney entertained a capacity crowd with songs spanning more than half a century, from Beatles classics to "Come On to Me" from 2018 album "Egypt Station".
Foo Fighters frontman Dave Grohl joined him for "I Saw Her Standing There" and "Band on the Run", receiving a rapturous welcome from the audience.
Following his "friend from the west coast of America", McCartney introduced another surprise "from the east coast of America": Bruce Springsteen. The two played "Glory Days" and "I Wanna Be Your Man".
McCartney, one of the greatest songwriters of the 20th century with the late John Lennon, paid tribute to his former band mates in the near-three-hour show. He played George Harrison's "Something" and performed a virtual duet with Lennon on "I've Got a Feeling".
Grohl and Springsteen came back for the final encore of "The End" from "Abbey Road".
"Thank you Dave, thank you Bruce, thank you Glasto," McCartney said before leaving the stage.
Glastonbury Festival concludes on Sunday with Diana Ross playing the Sunday afternoon legend's slot and Kendrick Lamar headlining on the Pyramid Stage.