2000 and 2004 Olympics
Yao first played for China in the Summer Olympics at the 2000 Olympics Basketball Tournament, and he was dubbed, together with 7-foot teammates Wang Zhizhi and Mengke Bateer, "The Walking Great Wall".During the 2004 Athens Olympics, Yao carried the Chinese flag during the opening ceremony, which he said was a “long dream come true”.He then vowed to abstain from shaving his beard for half a year unless the Chinese national basketball team made it into the quarter-finals of the 2004 Olympics Basketball Tournament. After Yao scored 39 points in a win against New Zealand, China lost 58–83, 57–82, and 52–89 against Spain, Argentina and Italy respectively. In the final group game, however, a 67–66 win over the reigning 2002 FIBA World Champions Serbia and Montenegro moved them into the quarterfinals. Yao scored 27 points and had 13 rebounds, and he hit two free throws with 28 seconds left that proved to be the winning margin.He was selected to the All-Olympics team with his performance, averaging 20.7 points and 9.3 rebounds per game while shooting 55.9% from the field.
Yao led the Chinese national team to 3 consecutive FIBA Asian Championship gold medals, winning the 2001 FIBA Asian Championship, the 2003 FIBA Asian Championship, and the 2005 FIBA Asian Championship. He was also named the MVP of all three tournaments.
2006 World Championships
Yao's injury at the end of the 2005–06 NBA season required a full six months of rest, threatening his participation in the2006 FIBA World Championship. However, he recovered before the start of the tournament, and in the last game of the preliminary round, he had 36 points and 10 rebounds in a win against Slovenia to lead China into the Round of 16. In the first knockout round, however, China was defeated by eventual finalist Greece. Yao's final averages were 25.3 points, the most in the tournament, and 9.0 rebounds a game, which was fourth overall.
After having surgery to repair his fractured foot, Yao said that if he could not play in the Olympics, "It would be the biggest loss in my career to right now". However, he returned to play with the Chinese national team on July 17, 2008. On August 6, Yao carried the Olympic Flame into Tiananmen Square, as part of the Olympic torch relay. He also carried the Chinese flag and led his country's delegation during the opening ceremony. After China opened with a 101-70 loss to the United States, and an overtime defeat to Spain, Yao scored 30 points in a win over Angola, and 25 points in a three-point win against Germany, which clinched China's place in the quarterfinals. However, China lost to Lithuania in the quarterfinals by 26 points, eliminating them from the tournament. Yao's 19 points a game were the second-highest in the Olympics, and his averages of 8.2 rebounds and 1.5 blocks per game were third overall.