His colleague, Liu Boming, also briefly got his head out of the capsule to hand him the flag.
Mr Zhai wore a Chinese-made spacesuit thought to have cost between £5m and £20m ($10m-$40m) for the space walk.
The "yuhangyuan" (astronaut) was tethered to the capsule with an umbilical cable.
Mr Zhai retrieved an externally mounted experiment.
The third yuhangyuan on the mission is Jing Haipeng.
The Shenzhou VII capsule soared into orbit on a Long March II-F rocket from Jiuquan spaceport in north-west China on 25 September.
1958: Base for spaceflights built at Jiuquan, in Gobi desert
April 1970: China launches its first satellite into space
1990-2002: Shenzhou I-IV are launched to develop systems
Oct 2003: The first manned space mission launches on Shenzhou V
Oct 2005: The Shenzhou VI mission takes two men into space
Oct 2007: Chang'e-1 orbiter sent on unmanned mission to the Moon
The rocket put the Shenzhou capsule in a near-circular orbit more than 300km above the Earth.
Earlier, Zhang Jianqi, one of the chief engineers for China's space programme, said keeping three men in the spacecraft, and then sending one outside, would be a "big test".
"This is a big technological leap," he told state-run news agency Xinhua.
"The risks are quite high. Sending up three astronauts is a jump both in quantity and quality."
The ship is to release a 40kg (90lb) satellite which will circle the orbiter and beam back images to mission control.
At the end of the mission, the Shenzhou re-entry capsule will target a landing in north China's Inner Mongolia Autonomous Region.
China became only the third nation after the United States and Russia to independently put a man in space when Yang Liwei, another fighter pilot, went into orbit on the Shenzhou V mission in October 2003.
Two years later, Fei Junlong and Nie Haisheng completed a five-day flight on Shenzhou VI.
According to the Associated Press news agency, Xinhua posted an article on its website prior to the lift-off that was written as if Shenzhou VII had already been launched into space.
China's Shenzhou VII rocket blasts off
The article reportedly carried a date of 27 September and came complete with a dialogue between the astronauts.
Chinese media report that this latest mission is the "most critical step" in the country's "three-step" space programme.
These stages are: sending a human into orbit, docking spacecraft together to form a small laboratory and, ultimately, building a large space station.
The Shenzhou VIII and IX missions are expected to help set up a space laboratory complex in 2010.
China launched an unmanned Moon probe last year about one month after rival Japan blasted its own lunar orbiter into space.
SHENZHOU VII SPACECRAFT
1. Forward orbital module - crew live and work in this section, which contains scientific equipment. In future missions, this module may remain in orbit as part of a Chinese space station
2. Re-entry capsule - contains seats for three crew
3. Propulsion module - contains spacecraft's power unit and liquid fuel rocket system
4. Solar panels - spacecraft carries one pair of solar panels
5. Spacewalk - One yuhangyuan (astronaut) exits the orbital module on a tether. Another crew member stands just inside to assist in case of an emergency
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.