"Congratulations to all graduates, young and not so young. The future is yours," Yao wrote on Instagram.
Yao, 37, first enrolled at the Chinese school in 2011. The 7-foot-6 Naismith Memorial Basketball Hall of Fame inductee towered over the fellow graduates on Sunday at the ceremony. His parents also attended the event. Yao is a graduate off the Antai School of Economics and Management.
He also gave a commencement speech.
"I would like to thank my parents first as the reason that I decided to study at university was to fulfill my promise to them," Yao told his fellow graduates, according to Shine.
"At a certain stage in the future, you should try to combine your future with the future of the society, because that's how you can find larger space for yourself to explore," Yao said, according to CGTN.
"Let me quote a famous conversation that happened on a basketball court 11 years ago, 'This is going to be your league in a little while.' Trust me, when a man spends seven years in university to graduate at age 38, he knows what he's talking about."
Yao played nine seasons for the Rockets during his decorated NBA career. He sat out the 2009-2010 season due to an injury, but made the All-Star team in every other season. He was the No. 1 overall pick in the 2002 NBA Draft. He averaged 19 points, 9.2 rebounds, 1.9 blocks and 1.6 assists during his NBA career.
Yao also raked in more than $93 million in on the court salary during his NBA tenure.