Yao made it official Wednesday, telling a packed news conference in his hometown that a series of foot and leg injuries forced him to end his playing career at the age of 30.
"I will formally end my career," said Yao, the 7-fooot-6 center who became a household name in China before starting his NBA career with the Houston Rockets as the top draft pick in 2002.
Yao played eight seasons in the NBA, but missed 250 regular-season games over the past six years.
"Today is an important day for me and holds a special meaning for both my basketball career and my future," Yao said in comments translated into English. "I had to leave the court since I suffered a stress fracture in my left foot for the third time at the end of last year. My past six months were an agonizing wait. I had been thinking (about my future) over and over. Today I am announcing a personal decision, ending my career as a basketball player and officially retire. But one door is closing and another one is opening."
Yao said he will return to work with his former Chinese team, the Shanghai Sharks, with the possibility of becoming general manager. He plans to continue his philanthropic work with his Yao Foundation.
NBA Commissioner David Stern sent a message via video link.
"Yao Ming has been a transformational player and a testament to the globalization of our game," Stern said in a statement. "His dominant play and endearing demeanor along with his extensive humanitarian efforts have made him an international fan favorite and provided an extraordinary bridge between basketball fans in the United States and China."
Houston general manager Daryl Morey attended the farewell conference after getting permission from the NBA because the lockout prohibits contact with players.
He said he was tired from the long trip, but "I would be sorry if I wasn't here."
"It's a big moment," Morey said. "Yao had a sense of humor, a great attitude and sense of working together. I hope we can continue his culture in the NBA."
Yao entered the conference room at a five-star hotel dressed in a dark suit, after the master of ceremonies led a count down to his arrival.
Yao's wife, Ye Li, and their 14-month-old daughter, Yao Qinlei, and Yao's parents, Yao Zhiyuan and Fang Fengdi, were in the room. Qinlei was dressed in a red qipao, a traditional Chinese dress. He later appeared with his family on the stage to the applause and cheers of the room.
Yao thanked his family, friends, coaches in China and in Houston and fellow competitors such as Shaquille O'Neal "for making me a better player."
"I will be always with you," Yao said. "Thank you."
Despite news of Yao's pending retirement being out for several weeks, the actual announcement was treated with the pomp that Yao's appearances in China bring. Media were asked to sign up weeks in advance for the conference and show up two hours early to pass through airport-style security checks.
The Grand Shanghai Ballroom was crammed at the back with dozens of television cameras and black-suited security men outnumbered the hundreds of media. China Central Television planned to carry five continuous hours of Yao coverage beginning at 1 p.m. local time, including 90 minutes live from the media conference.
Yao's contract expired after last season, and the Rockets said they were interested in re-signing him if he came back healthy. Yao said in April in China that his professional future depended on his recovery from a stress fracture in his left ankle.
Selected to the NBA All-Star team eight times, Yao averaged 19 points and 9.2 rebounds. More importantly, his impact expanded the NBA's influence in Asia into lucrative merchandise sales and TV ratings.
After his rookie season, Yao helped the Rockets reach the playoffs in the next two seasons.
Yao played in 77 games in the 2008-09 season, when Houston reach the second round of the playoffs for the first time since 1997.
But Yao broke his left foot in a playoff game against the Los Angeles Lakers, and underwent complex surgery that sidelined him for the entire 2009-10 season. He lasted only five games at the start of the 2010-11 season, before breaking his left ankle. He had surgery in January, and was lost again for the season.
Yao had played six years with the Chinese national team before joining the Rockets, and was already a star in his home country. He carried the Olympic torch through Tiananmen Square and his country's flag during the opening ceremonies at the Beijing Olympics in 2008. He also donated $2 million and set up a foundation to rebuild schools in the wake of the 2008 earthquake in Sichuan.