The couple are the founders and co-chairs of the Bill & Melinda Gates Foundation, the world's largest private foundation.
"Melinda and I are excited to be here ... Stanford is rapidly becoming the favorite university for members of our family and it's long been a favorite university for Microsoft and our foundation, " Gates told a big crowd that had gathered at the Stanford Stadium.
He went on to talk about his foundation's current research, the advent of the personal computer and its future.
"Some people call you all nerds, and we hear that you claim that label with pride," Melinda Gates told graduates.
"Well, so do we," her husband responded, with the two of them putting on their "nerd glasses" to applause from the audience.
Melinda Gates tweeted out a picture of her own graduation from Duke University Thursday, saying: "Thinking about my graduation from Duke as @BillGates and I prep for #Stanford14 commencement this weekend. #TBT"
On Sunday, she tweeted pictures of herself and Bill Gates getting ready for the commencement ceremony.
"Sharing a mutual commitment to a better world, Bill and Melinda Gates have taken on some of the planet's toughest challenges," Stanford president John Hennessy said. "This boldness is an ethos that we also embody at Stanford, and one we seek to instill in our graduates."
— Melinda Gates (@melindagates) June 12, 2014
— Melinda Gates (@melindagates) June 14, 2014
— Melinda Gates (@melindagates) June 15, 2014