His performance concluded what festival organiser Michael Eavis hailed as the best Glastonbury he had known since launching it in 1970.
"The feedback from the public has been absolutely amazing this year but I can't take the credit for it - I think the sun takes most of the credit."
Bowie delved into his back catalogue as he rattled through a succession of festival crowd-pleasers.
"I'd just written this the first time I played Glastonbury in 1971," said Bowie as he launched into Changes.
Streaker
Later the singer recalled how at his previous appearance he had stayed at Worthy Farm, the home of Mr Eavis and had a "bottle of tincture of cannabis for medicinal purposes only."
Earlier, the re-formed Happy Mondays had a female streaker during their set who danced on a platform in the space between the crowd and main stage before then gyrating in the centre of the stage - to the amusement of the band.
The band ran through many of their biggest hits including Wrote For Luck, Hallelujah and Kinky Afro as well as a track by singer Shaun Ryder's other now defunct outfit, Black Grape.
The three-day event has seen performances from a catalogue of top acts including Travis, Moby, Fatboy Slim and Macy Gray.
Early rain showers on Thursday did not return and sunshine beamed down sporadically throughout the event, ensuring no repeat of previous Glastonbury mud baths.
Show-stopping
Even a show-stopping performance by guitar band Travis - renowned for prompting showers when they play their hit Why Does it Always Rain on Me? at outdoor festivals - failed to cause the heavens to open.
Singer Fran Healy told the crowd: "I think this year we've broken the hex because it hasn't rained a single drop yet and I'm happy about that.
The front man was clearly overwhelmed as he took the stage in front of massive crowds.
"It doesn't get much better, does it?" he said.
Michael Eavis was delighted the weather had held out. "The whole thing is dependent on the weather. The weather really keeps people going," he said.
Security clampdown
He estimated that as well as the 100,000 who had paid or were working at the event, a further 10-15,000 had sneaked in or paid back-handers to security staff to gain entry.
Eavis announced plans to invest in a £1 million security fence to clamp down on the problem in future years.
Other security difficulties at the event included more than 1,000 reported crimes.
Police had logged 1,322 crimes by this afternoon - 1,047 of those were thefts from or of tents, with 115 robberies.
They had also made 207 arrests for offences such as robbery, possession of drugs, violent disorder and even indecent exposure.
Seventy three people have been charged and a further 33 cautioned and ejected from the site.